1.4.2.3 - error message instead of gallery main page

Hi, after I upgraded to 1.4.2.3 (latest attempt was with latest nightly),

instead the gallery's main page I see error message
Fatal error: Call to a member function getNumImages() on a non-object in ..../zp-core/template-functions.php on line 1654

I can see and navigate inside albums by pointing directly to their address. But link to the main page on the top gives weird url - instead the proper gallery url there is additional /page/2/ at the end ( http://my.gallery.url/page/2/).

Downgrading to 1.4.2.2 solved the issue for this time.

Comments

  • What theme are you running? This error is because a function for returning the number of images in an album was called when there was not an album present. (As might be the case on the gallery index.)
  • Default theme. It's "improved" copy for my needs but no matter - switching to the "original" default didn't help.
  • Well, just tested one idea and now everything is OK.

    Commented out 3 lines from template-functions.php
    1624 - if (getNumImages()) {
    1629 - }
    1630 - return false;

    The /page/2/ seems to be normal as albums in gallery index are on 2 pages.
  • Well, those lines of code reside in the function `isImagePage()` which does not appear at all in the `Default` theme. At least certainly not in the 1.4.2.3 nightly build.
  • Jaanus Member
    what are those lines exactly for? Maybe I miss now some useful feature?
  • acrylian Administrator, Developer
    Returns true if this page has image thumbs on it
    Description of the function. Means this is an page with thumbs and not only subalbums.
  • Jaanus Member
    It's still problematic. Now after I installed a new version (nightly beta) the first gallery page just returned blank. Also with original "Default" template for 1.4.3!

    Again I had to comment out these three lines in template-functions.php

    Are you really sure that these lines are necessary? Without them my site works normally, no side effects.

    function isImagePage() {
    // if (getNumImages()) { //Jaanus commented out
    global $_zp_page, $_firstPageImages;
    $imagestart = getTotalPages(2); // # of album pages
    if (!$_firstPageImages) $imagestart++; // then images start on the last album page.
    return $_zp_page >= $imagestart;
    //} Jaanus commented out
    //return false; //Jaanus commented out
    }
  • `isImagePage()` STILL is not part of the standard `Default` theme! So commenting out those lines CANNOT have any impact on it.
  • Jaanus Member
    OK, but how those lines in template-functions.php should make the newer versions better than 1.4.22 if they "CANNOT" have any impact?

    Is it needed for other templates?

    Where (in which file) to look for the bug?

    May it be because php version is earlier than 5.3 (5.2.17) ?

    Etc etc etc
  • If you are calling the function from a place not setup for it you will get an error. But the standard `default` theme does not use this function. Look in your changes.
  • Jaanus Member
    Indeed.... one separate test page shows everything without problems.

    So I'm confused. Where could be the "place not setup for it"?

    I'm pretty sure it should be somewhere else than theme files - as in my gallery page I got the same error with original "default" template where I hadn't changed anything.

    Could some 3rd party plugin generate such error?
  • You should search for the use of `isImagePage()` since that is apparently the source of your problem. Certainly it could be being used by third party themes or plugins.
  • Jaanus Member
    Well, your hint helped me and the source of my problem was found on 1st attempt :)

    It was zenFBcommon.php (from the Facebook plugin). I don't know why but error generating code was on line 84:

    if (isImagePage()) {
    echo '<meta property="og:image" content="http://' . $_SERVER['HTTP_HOST'] . getUnprotectedImageURL() . '" />';
    }

    Perhaps you don't want to know how I solved it :)

    At least temporarily it says now that "if this is not an album page":

    if (!isAlbumPage()) {
    echo '<meta property="og:image" content="http://' . $_SERVER['HTTP_HOST'] . getUnprotectedImageURL() . '" />';
    }

    Tested. It works. Picture is normally posted to my FB wall.
  • Jaanus Member
    Have to be honest. I believed that I had the latest version of zenFBsuite, but updated it now just in case. And everything is fine without need to change somewhere the code.

    Sorry for this panic :(
  • acrylian Administrator, Developer
    Good that we figured it out. I think those checks are not correct and meant to check the theme page. That should actuallyl be done by using the `$_zp_gallery_page`and checks for `album.php` or `image.php`. I will point its developer to this topic so he can fix it.
  • I'll take a look, but I never ran into any issues like that. What I was aiming for with the isImagePage() was attempting to use the function as the documentation said, which is "Returns true if this page has image thumbs on it"

    Up until now this is the first I've heard of that being incorrect or having any errors. Did something change in the usage of this function?

    Edit:
    As a clarification, I understood the documentation to mean that it will return true if there's an image thumbnail on the page, no matter what page is loaded. For instance, a news page that has an image on that, for a FB link the user would most likely want to use one of the thumbnails from the news page and not their general image.
  • acrylian Administrator, Developer
    No, those functions did not change. isImagePage() is meant to check if we have thumbs on a album.php page if the album has images and sub albums. I agree that the doc is not really clear what this is about...

    There is no way to check if there is any thumb in general on a page and specifically not on a news or pages page.

    Your only chance is to check for the actual theme page.
  • Hmm... ok I'll have to address this then. Thanks for the clarification.
  • acrylian Administrator, Developer
    Take a look at the html meta tags plugin as that does basically the same things technically.
  • Jaanus Member
    Well, as I said in my previous post - after updating fbsuite everything became normal and I hadn't to make any more those changes I mentioned earlier.

    I just used some (perhaps not much but still) older version that caused my problem. So I tried to fix the older, not the most actual version :S
  • Jaanus Member
    Just looked into the actual zenFBcommon.php
    and as I saw there is not isImagePage() at all.
  • Yah, I think I had removed it come to think of it because it wasn't doing what I expected. Now that my work scheduled has settled some, I *should* be able to dive into the plugins and release the html5 compliant versions either this weekend or the next.
Sign In or Register to comment.