printAlbumzip () fails - persistence?

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:
`

<?php<br />
if (function_exists ('printAlbumZip')) { printAlbumZip();}

?>

`

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!

Comments

  • This is probably a context issue with the codeblocks. Try adding the `global $_zp_current_album;` before the `printAlbumZip();` call.
  • teeps Member
    I changed the codeblock to:
    `<<br />
    ?php

    if (function_exists ('printAlbumZip')) {

    global $_zp_current_album;

    printAlbumZip();}

    ?>

    `

    Unfortunately I still get the same error.
  • Well the error is caused by $_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 $_zp_current_album is before your call.
  • teeps Member
    In the codeblock:
    Echoing $_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 $_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= '.$_zp_gallery->getTitle();

    echo 'album= '.$_zp_current_album->getTitle ();

    `

    Now I get the 'Call to a member function getTitle() on a non-object' error on that second echo (the $_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.

  • teeps Member
    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?
  • teeps Member
    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 $_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.
  • teeps Member
    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 ($persist = $_zp_gallery->getPersistentArchive();) and adding $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.
  • So then, the problem is only if the persistent arcive option is set? (You can reset that on the options page to be sure.)
  • teeps Member
    I get the same result whether the persistent archive option is set or cleared.
  • change that line to `$persist = $zip_gallery->getPersistentArchive();` and let us know if the problem is solved.
  • teeps Member
    That seems to have solved it, thanks sbillard!
Sign In or Register to comment.