zenphoto forums » Bug Discussion

getCommentCount() Bug

(8 posts)
  • Started 4 years ago by joshrodgers
  • Latest reply from joshrodgers
  1. joshrodgers

    Member
    Joined: Jul '08
    Posts: 35

    I have ZenPHOTO 1.2.3 installed and the getCommentCount() function didn't work. Not sure why, it just didn't. If anyone else has the same problem just download ZenPHOTO 1.2.1 and replace:


    function getCommentCount() {
    global $_zp_current_image, $_zp_current_album, $_zp_current_zenpage_page, $_zp_current_zenpage_news;
    if (in_context(ZP_IMAGE) & in_context(ZP_ALBUM)) {
    if (is_null($_zp_current_image)) return false;
    return $_zp_current_image->getCommentCount();
    } else if (!in_context(ZP_IMAGE) & in_context(ZP_ALBUM)) {
    if (is_null($_zp_current_album)) return false;
    return $_zp_current_album->getCommentCount();
    }
    if(function_exists('is_News')) {
    if(is_News()) {
    return $_zp_current_zenpage_news->getCommentCount();
    }
    if(is_Pages()) {
    return $_zp_current_zenpage_page->getCommentCount();
    }
    }
    }

    with:


    function getCommentCount() {
    global $_zp_current_image, $_zp_current_album, $current_zenpage;
    if (in_context(ZP_IMAGE) AND in_context(ZP_ALBUM)) {
    return $_zp_current_image->getCommentCount();
    } else if (!in_context(ZP_IMAGE) AND in_context(ZP_ALBUM)) {
    return $_zp_current_album->getCommentCount();
    }
    if(function_exists('is_News')) {
    if(is_News() OR is_Pages()) {
    return $current_zenpage->getCommentCount();
    }
    }
    }

    Not sure if that is the recommended procedure -- but it fixed my problem. *I tried to highlight this in green. If it doesn't work my apologies.

    Josh

    Posted 4 years ago #
  2. Zenphoto development team
    acrylian

    Developer
    Joined: Jul '07
    Posts: 13,479

    This is of course not recommened procedure! For example this code is not compatible with the Zenpage plugin. Recommended is to try the nightly build if you encounter issues with the last official version. The issue might already been fixed there.

    Don't forget to read the Forum rules and usage resources
    Posted 4 years ago #
  3. joshrodgers

    Member
    Joined: Jul '08
    Posts: 35

    I tried the nightly build before trying this method. I know this code might not be compatible with Zenpage, but at least it's working!! I am not using Zenpage, so I didn't notice. I know this isn't the recommended route, but this worked for me. Hopefully it will work for others who encounter this issue (and don't have Zenpage installed). Hopefully this will be fixed when the next version is released or in the next nightly build. Just wanted to provide a fix and report a bug. Thanks,

    Josh

    Posted 4 years ago #
  4. Zenphoto development team
    sbillard

    Chief Developer
    Joined: May '07
    Posts: 9,818

    Tell me more! If you are not using zenpage, then the code differences appear to be the test on the current image or album being NULL in which case false is returned. The code you copied just will fault in those cases, so I cannot see how it has fixed your problem.

    Don't forget to read the Forum rules and usage resources
    Posted 4 years ago #
  5. joshrodgers

    Member
    Joined: Jul '08
    Posts: 35

    Ok, I compared each line and noticed what is causing the problem.

    There are only two places that need to be changed.

    The original code is:


    if (in_context(ZP_IMAGE) & in_context(ZP_ALBUM)) {

    It should be:


    if (in_context(ZP_IMAGE) AND in_context(ZP_ALBUM)) {

    ================================================================

    The next change is:

    The original code is:


    } else if (!in_context(ZP_IMAGE) & in_context(ZP_ALBUM)) {

    It should be:


    } else if (!in_context(ZP_IMAGE) AND in_context(ZP_ALBUM)) {

    ================================================================

    Use "AND" instead of the "&". That's all I did and it fixed it. Now my code looks like:


    function getCommentCount() {
    global $_zp_current_image, $_zp_current_album, $current_zenpage, $_zp_current_zenpage_news;;
    if (in_context(ZP_IMAGE) AND in_context(ZP_ALBUM)) {
    if (is_null($_zp_current_image)) return false;
    return $_zp_current_image->getCommentCount();
    } else if (!in_context(ZP_IMAGE) AND in_context(ZP_ALBUM)) {
    if (is_null($_zp_current_album)) return false;
    return $_zp_current_album->getCommentCount();
    }
    if(function_exists('is_News')) {
    if(is_News()) {
    return $_zp_current_zenpage_news->getCommentCount();
    }
    if(is_Pages()) {
    return $current_zenpage->getCommentCount();
    }
    }
    }

    Posted 4 years ago #
  6. joshrodgers

    Member
    Joined: Jul '08
    Posts: 35

    Copied the wrong thing. My code now looks like:

    function getCommentCount() {
    global $_zp_current_image, $_zp_current_album, $_zp_current_zenpage_page, $_zp_current_zenpage_news;
    if (in_context(ZP_IMAGE) AND in_context(ZP_ALBUM)) {
    if (is_null($_zp_current_image)) return false;
    return $_zp_current_image->getCommentCount();
    } else if (!in_context(ZP_IMAGE) AND in_context(ZP_ALBUM)) {
    if (is_null($_zp_current_album)) return false;
    return $_zp_current_album->getCommentCount();
    }
    if(function_exists('is_News')) {
    if(is_News()) {
    return $_zp_current_zenpage_news->getCommentCount();
    }
    if(is_Pages()) {
    return $_zp_current_zenpage_page->getCommentCount();
    }
    }
    }

    Posted 4 years ago #
  7. Zenphoto development team
    sbillard

    Chief Developer
    Joined: May '07
    Posts: 9,818

    You have a better eye than I. That & should have been && which it is in the current nightly build. So I guess that this problem has already been fixed.

    Don't forget to read the Forum rules and usage resources
    Posted 4 years ago #
  8. joshrodgers

    Member
    Joined: Jul '08
    Posts: 35

    Guess so. Thanks for the help.

    Josh

    Posted 4 years ago #

RSS feed for this topic

Reply

You must log in to post.