Member
Member
teeps   04-07-2011, 22:14
#1

Hi,

Any time I try to use the printAlbumzip function on an album I get this error:
Fatal error: Call to a member function getPersistentArchive() on a non-object in /home/content/65/8079365/html/zenphoto/zp-core/album-zip.php on line 66

This is the code I've added into a codeblock to call the function:
`

`

I've enabled persistent archives in the options, not sure if that has helped as the same error is given either way.

Does this function work for others, or is this a wider problem not specific to me?

Thanks!

Member
Member
sbillard   04-07-2011, 23:12
#2

This is probably a context issue with the codeblocks. Try adding the global $_zp_current_album; before the printAlbumZip(); call.

Member
Member
teeps   05-07-2011, 05:47
#3

I changed the codeblock to:
`<

?php

if (function_exists ('printAlbumZip')) {

global &#36;_zp_current_album;

printAlbumZip();}

?>

`

Unfortunately I still get the same error.

Member
Member
sbillard   05-07-2011, 16:13
#4

Well the error is caused by &#36;_zp_current_album not being an object. If the global did not help then there is some other reason. Perhaps the codeblock call is out of the scope of album context.

Do some debug output--see what the value of &#36;_zp_current_album is before your call.

Member
Member
teeps   05-07-2011, 17:37
#5

In the codeblock:
Echoing &#36;_zp_current_album->getTitle () gives me the correct title of the album, so it looks like it is picking the right album object.

Just for info I echoed &#36;_zp_gallery->getTitle () but that just returned an empty result.

So next I added these lines to album-zip.php just before the line that was giving me a problem:
` echo '';

echo 'gallery= '.&#36;_zp_gallery->getTitle();

echo 'album= '.&#36;_zp_current_album->getTitle ();

`

Now I get the 'Call to a member function getTitle() on a non-object' error on that second echo (the &#36;_zp_gallery one), so it looks like it's losing the context somewhere maybe? I'm not great on classes and objects, so this is guesswork for me.

Member
Member
teeps   06-07-2011, 03:44
#6

I just noticed that the link being called by the printAlbumZip() function is wrong - it's passing the album title in lowercase, i.e. http://mydomain.net/zenphoto/zp-core/album-zip.php?album=randoms

If I manually change the url in the browser window to use the correct case for the album title (i.e. with a capital R, as in album-zip.php?album=Randoms) I do not get the 'non-object' error - I still don't get a zip file but that's another problem.

How can I ensure that the printAlbumzip function passes the correct album name with the correct case?

Member
Member
teeps   06-07-2011, 03:51
#7

I changed line 3081 in template-functions.php to
`echo'getTitle()) .

        '" title="'.gettext('Download Zip of the Album').'">'.gettext('Download a zip file of this album').'';`

Previously it used &#36;_zp_current_album->name in the pathurlencode function. After this change it passes the correct album title and I don't get the non-object error. I am still looking into why I don't get a zip file output.

Member
Member
teeps   06-07-2011, 04:58
#8

Forget the previous two posts (especially as the code went funny in the last one), apparently using getTitle() is a red-herring. I tried it with an album that is named in lowercase and it gave the non-object error again, so I deduce that album names are in fact lower case, and that's what needs to be passed. Giving a name with upper case produces the same as giving album-zip.php a completely made up name.

So, next I tried commenting out line 66 of print-album.zip (&#36;persist = &#36;_zp_gallery->getPersistentArchive() and adding &#36;persist = NULL; instead. This works in the sense that the zip file is created, but presumably there's no caching going on, so every request will create a new file.

Member
Member
sbillard   06-07-2011, 16:21
#9

So then, the problem is only if the persistent arcive option is set? (You can reset that on the options page to be sure.)

Member
Member
teeps   06-07-2011, 18:05
#10

I get the same result whether the persistent archive option is set or cleared.

Member
Member
sbillard   06-07-2011, 18:41
#11

change that line to &#36;persist = &#36;zip_gallery->getPersistentArchive(); and let us know if the problem is solved.

Member
Member
teeps   06-07-2011, 18:47
#12

That seems to have solved it, thanks sbillard!

  
Powered By MyBB, © 2002-2026 MyBB Group.
Made with by Curves UI.