Error creating new album

jsteinhu

Joined: 2002-09-03
Posts: 37
Posted: Tue, 2002-09-03 21:14

I changed my web server and reinstalled all the software. [For another reason] I am currently using 1.3.2-cvs-b3. Everything is working great. [Better then it used to; I never could get mod_rewrite working on my old box] Except that whenever I create a new album I get this error message: "Fatal error: Call to a member function on a non-object in d:htdocsgallerydo_command.php on line 104". The album is created but is left in the top level of the gallery. I can then move it and rename it just fine. As you can see at http://redacted/

Win2000
Apache
PHP [not safe mode]
Gallery 1.3.2-cvs-b3

I have looked through the FAQ and these forums and couldn't find a simelar problem.

 
vallimar

Joined: 2002-08-15
Posts: 487
Posted: Wed, 2002-09-04 01:29
Quote:
d:htdocsgallerydo_command.php on line 104

Assuming that's a straight quote of the error messages, it looks
like the path information is not properly set? Is it stripping out
your slashes for some reason?

 
bharat
bharat's picture

Joined: 2002-05-21
Posts: 7994
Posted: Wed, 2002-09-04 05:27
Quote:
>>d:htdocsgallerydo_command.php on line 104<<
Assuming that's a straight quote of the error messages, it looks
like the path information is not properly set? Is it stripping out
your slashes for some reason?

That's probably the forum that's stripping out the slashes; the path is probably ok.
(stupid forum! :smile: )

jsteinhu, is this happening when you create a top level album? Or only when you create a sub-album? And if it's only for sub-albums (which is my guess, from looking at the code) does it happen no matter which album you try to create the sub-album inside?

-Bharat

 
jsteinhu

Joined: 2002-09-03
Posts: 37
Posted: Wed, 2002-09-04 13:06

The path is correct, I guess I should have gone through and escaped the slashes. :smile: bharat, you were correct, it turns out when I looked for it, that it doesn't happen when creating a top-level album but only when creating sub-albums. It does occur in all the albums I have tested be they 2nd or 3rd level. Let me know if there is an experiment you would like me to try with the code, I don't know PHP but I am a programmer.

 
bharat
bharat's picture

Joined: 2002-05-21
Posts: 7994
Posted: Thu, 2002-09-05 04:24

Humm. I'm not sure what's going on, so we'll have to do some collaborative debugging. Line 103 of do_command.php looks like this:

$parentAlbum = $albumDB->getAlbumbyName($parentName);

right after that line put:

print "<pre>";
print "parent album: [$parentName]n";
print_r($parentAlbum);
print "</pre>";

Leave it in debug mode and try to create a new album. Capture the results and post them here.

 
jsteinhu

Joined: 2002-09-03
Posts: 37
Posted: Thu, 2002-09-05 14:15

Okay, when I try to make a nested album in the top-level album "Josh" this is what I get on the error page:

"parent album: [josh]
0

Fatal error: Call to a member function on a non-object in d:\htdocs\gallery\do_command.php on line 108"

It looks to me like the getAlbumByName is having a problem, which is odd because there is no problem elsewhere in the code. Maybe my album database has become corrupt? I don't know what to look for but it is, currently, publically readable in my /album directory on the server mentioned above.

Thanks for thinking about this,
Josh

 
vallimar

Joined: 2002-08-15
Posts: 487
Posted: Fri, 2002-09-06 05:37

Do you get the error even if you create a new top-level album then
try to create sub-albums beneath that? What happens if you create it
as a top-level, then try to move it inside another album?

 
jsteinhu

Joined: 2002-09-03
Posts: 37
Posted: Fri, 2002-09-06 14:19

Wow, that creates some new interesting errors! Here is what I am trying per your request:

1] Create a new top-level album.

This works great. THe album is created and placed as the first album on the top-level gallery. [I forgot to mention that when making a nested album fails, the album is placed at the bottom of the top-level list of albums.

2] Create a sub album in this new album.

Although this appears to succeed and places the new newsted album in the correct place, I get this long error:

-----
parent album: [album01]
album Object
(
[fields] => Array
(
[title] => Untitled
[description] => No description
[nextname] => aaa
[bgcolor] =>
[textcolor] =>
[linkcolor] =>
[font] => arial
[border] => 1
[bordercolor] => black
[returnto] => yes
[thumb_size] => 150
[resize_size] => 640
[rows] => 3
[cols] => 3
[fit_to_window] => no
[use_fullOnly] => no
[print_photos] => none
[use_exif] => yes
[perms] => Array
(
[canRead] => Array
(
[everybody] => 1
)

)

[parentAlbumName] => 0
[clicks] => 1
[clicks_date] => 1031321718
[display_clicks] => yes
[public_comments] => yes
[serial_number] => 0
[name] => album01
[owner] => 1018745208:881994106
[last_mod_time] => 1031321718
)

[photos] =>
[dir] =>
[version] => 4
[tsilb] => TSILB

[transient] =>
[updateSerial] => 0
)

Warning: Cannot add header information - headers already sent by (output started at d:htdocsgallerydo_command.php:104) in d:htdocsgallerydo_command.php on line 141
-----

The final warning might be related to the code that bharat has me add to do_command. The odd thing is that I do NOT get this same error when adding an album to ANY pre-exisiting top level album.

As to your second query, creating the album at the top level and then moving it works perfectly.

Should I try 1.3.2-cvs-b4? has any of the code in this area been changed?

 
vallimar

Joined: 2002-08-15
Posts: 487
Posted: Sat, 2002-09-07 04:37

I don't believe any changes in CVS would have much affect on this.
Try commenting out the lines Bharrat had you add and see if that
error goes away in the new album. If it does, and the new album
is working fine, it could be that your other top level album has some
corrupted info in it.

 
jsteinhu

Joined: 2002-09-03
Posts: 37
Posted: Sat, 2002-09-07 15:03

I reverted the do_command.php back to the 1.3.2-cvs-b3 version and as you suspect it works fine if I create a new top-level album. So perhapes the album is corrupted. [Or has there been a very subtle change in the definition of album.dat?] It is odd that all the albums would get corrupted exactly when upgrade. Any idea how to audit my album.dat and/or correct it?

 
bharat
bharat's picture

Joined: 2002-05-21
Posts: 7994
Posted: Sat, 2002-09-07 20:15

When you saw this:

Quote:
"parent album: [josh]
0

It means that Gallery was unable to load the "josh" album for some reason, so it was unable to add your new album as a child of it. I checked out your albums remotely
and I think the problem is that it's got carriage returns in it.

You say that you transferred your website. What operating system did you transfer from? And how did you move the files over?

Try running dos2unix on your Josh album.dat file (make a backup first!) and see if that fixes the problem.

 
jsteinhu

Joined: 2002-09-03
Posts: 37
Posted: Sun, 2002-09-08 03:19

Good catch! I wonder if WinZip did that... However, no progress. :smile: I ran dos2unix on albums/josh/album.dat and I get the exact same error when trying to create a sub-album. I even tried making it one line instead of two. [All the album.dat files on my gallery have a newline before the quote mark after the serial number near the end -- is that normal?] Is there a different peice of code that reads the database for creating a new album then all the parts of the program that read out of it? I guess this will be a problem that will go away in 2.0.

I really appreciate the effort you all have put into the program and this problem.
Josh

 
vallimar

Joined: 2002-08-15
Posts: 487
Posted: Sun, 2002-09-08 05:48

Well, if new albums work without any problems, and the old one
can't seem to be fixed easily, you may just want to recreate it.

You can use the local directory option of add photos and point it to your
non-working ones. Just uncheck all the thumbs and resized images.

I know this is a poor workaround but something seems to have happened
to your old album.dat file and the normal solutions aren't working, so...

 
bharat
bharat's picture

Joined: 2002-05-21
Posts: 7994
Posted: Mon, 2002-09-09 09:35

If you were on Unix, I'd offer to log on remotely and try to debug this. If you can offer up ssh access (there are ssh daemons for win32, right?) I'm willing to try to figure this out for you. Let me know.

 
jsteinhu

Joined: 2002-09-03
Posts: 37
Posted: Mon, 2002-09-09 14:32

There are indeed ssh servers, and I am running one. However I am not allowed to give out access per local security policy. :smile: Thank you for the offer though. Perhapes I could make a pared down version of my albums directory, a minimal example that doesn't work, and post a link to that? [I would back my whole gallery up and then delete almost all the albums to make a .zip/.tgz file]

Heck, I just did it http://redacted/ It is only ~1.7MB but still has the problem. I don't know if this will be good enough to help, but there we are. Otherwise, I guess I'll start from a clean slate and copy the images/captions over manually.

Josh

 
bharat
bharat's picture

Joined: 2002-05-21
Posts: 7994
Posted: Tue, 2002-09-10 03:35

Ok, this is strange. I downloaded your zip file and dropped the Josh and JoshWierd albums into my albums directory on my Win2K box. It worked perfectly and I was able to add nested albums under both the Josh and the JoshWierd albums without difficulty.

I'm running Gallery 1.3.2-cvs-b4 on a FoxServ 2.x installation (which is Apache 1.3.22 and PHP 4.0.6). I don't think anything has changed in v1.3.2 to fix this. In fact, I can't even see what might be wrong with the album.dat files. They look good to me.

My guess is that this is a bug in the PHP deserialization code. What version of PHP and Apache are you using?

 
jsteinhu

Joined: 2002-09-03
Posts: 37
Posted: Tue, 2002-09-10 18:34

Well, this is strange. I am running Apache/1.3.26 (Win32) with PHP/4.2.2 I tried reinstalled gallery, using the same album directory but a fresh copy of gallery (in this case 1.3.2-cvs-b4) downloaded straght off the net. I saw on this board that there is a update of php that fixes some windows directory bugs. I have now installed PHP/4.2.3, but no change in the behavior.

Josh

 
jsteinhu

Joined: 2002-09-03
Posts: 37
Posted: Wed, 2002-09-11 05:09

Here is an idea, is my albumdb.dat okay? I ask since you were able to insert my albums into a working gallery.

 
bharat
bharat's picture

Joined: 2002-05-21
Posts: 7994
Posted: Wed, 2002-09-11 17:40

The albumdb.dat file is just a cache. Typically it's safe to blow it away.

Are you free to do some serious experimentation on your server? I'd be curious what happens if you install PHP 4.0.6, or just install FoxServ 2.0 so that you have what I have.

 
EvZ

Joined: 2002-09-11
Posts: 2
Posted: Wed, 2002-09-11 20:19

I had the same problem on win2000, apache 1.3.26, php 4.2.2, gallery 1.3.1

The problem only occured when I used albumnames with capitals like: WBbZfG1bzG
Changing the name in wbbzfg1bzg solved the problem.

 
jsteinhu

Joined: 2002-09-03
Posts: 37
Posted: Thu, 2002-09-12 22:39

Thanks a lot EvZ! That fixed it like a charm. For example I changed JoshWeird->joshweird and so on. Everything works perfect again. I did try downgrading to PHP4.0.4p11 as you asked bharat but the session feature stoped working, possibly because of an incompatabile php.ini. There must be something odd going on in either PHP or gallery regarding window's odd remembering but not caring attitude to capital letters. It also would explain why the albums worked for you bharat, your comments made it sound like you code and use a unix OS. I am not sure what the real solution is but this should be a good clue. If I get time maybe I'll check the code out from cvs and see if I can make a patch.

I have been so happy with this progam and the support from the community that I am going to find somebody at work who has paypal and donate some money towards webhosting costs...

Josh

PS> I am removing the URL's from the previous posts. Let me know if you wish to see them for some reason.

 
jsteinhu

Joined: 2002-09-03
Posts: 37
Posted: Thu, 2002-09-12 23:45

The following patch to the main CVS branch appears to fix the problem for me. Perhapes you can consider something like it bharat? This should really be split into the platform specific files since on unix you would want to allow for albums [i.e. directories] to have different capitilization but on windows that can't happen. I'll take a look at how you do the platform stuff and see if I can make a more complete patch.

Josh

$ cvs diff -c AlbumDB.php
Index: AlbumDB.php
===================================================================
RCS file: /cvsroot/gallery/gallery/classes/AlbumDB.php,v
retrieving revision 1.13
diff -c -r1.13 AlbumDB.php
*** AlbumDB.php 11 Sep 2002 04:29:32 -0000 1.13
--- AlbumDB.php 12 Sep 2002 23:40:35 -0000
***************
*** 139,145 ****
$list = $this->albumList;
$indexLimit = count($list);
for ($i=0; $i<$indexLimit; $i++) {
! if ($list[$i]->fields["name"] == $name) {
return $list[$i];
}
}
--- 139,145 ----
$list = $this->albumList;
$indexLimit = count($list);
for ($i=0; $i<$indexLimit; $i++) {
! if (0==strcasecmp($list[$i]->fields["name"], $name)) {
return $list[$i];
}
}

 
Micronix

Joined: 2002-12-27
Posts: 9
Posted: Tue, 2003-01-21 00:21

Hey, I am having the same problem on win2k, php4.2.3. And I am also named Josh. Anyway, jsteinhu, can you explain what this last post means and how I go about implementing the fix... or was the fix just to use all lowercase names? I am using gallery 1.3.2. b4 and my albumDB.php does not seem to have those lines in line 139-145... can you help explain how I might implement the fix? Dang, I just noticed this is kind of an old thread, are people still getting this problem besides me?

 
jsteinhu

Joined: 2002-09-03
Posts: 37
Posted: Tue, 2003-01-21 02:32

Yeah my patch never made it into the code. I can't see why people don't get this problem all the time since is seems simply incorrect... Anyhow to sum up you have two options:

1] Have no album who's on-disk name has capital letters; or
2] Patch the code like I described above. [I think I described a quick hack and a better cross-platform one]

I just looked at the HEAD of the CVS tree and in AlbumDB.php there is a function:
function getAlbumbyName($name) {
global $gallery;
foreach ($this->albumList as $album) {
if ($album->fields["name"] == $name) {
if (!$album->transient->photosloaded) {
$album->loadPhotos($gallery->app->albumDir . "/$name");
}
return $album;
}
}
return 0;
}

Maybe the etra context will help you find it after a couple months of code changes.

Hope this helps, if there is interest from someone with commit authority I will refresh my patch and resubmit it.

Josh

 
bharat
bharat's picture

Joined: 2002-05-21
Posts: 7994
Posted: Tue, 2003-01-21 04:58

For what it's worth, I've still got the patch but since it's an infrequently reported problem it's been low on my patch-priority-list for a long time :-/