getCommentCount() Bug

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

Comments

  • acrylian Administrator, Developer
    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.
  • 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
  • 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.
  • 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();

    }

    }

    }

    `
  • 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();

    }

    }

    }

    `
  • 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.
  • Guess so. Thanks for the help.

    Josh
Sign In or Register to comment.