v1.2.6 - Spamassassin

Hello,

I noticed Spamassassin module was removed from core Zenphoto package.
Never mind, I downloaded it.
Right now, I have one major error...

When a comment has to be rejected, I have the following error message:
Comment Error "3" not defined

I checked my code.
When the comment is considered as spam, I send a 0.
When it has to be moderated, I send a 1
When it's ok, I send a 2

I checked in zp-core/functions.php, zp-core/plugins/comment_form.php but I didn't find anything about this number 3.

Could someone provide me some tips on how to track down this error?

Here is the end of the (modified) code:

`
if ($isSpam === true) {
$forgive = getOption('SA_Forgiving');
return $forgive;
}
else {
$forgive=2;
}
return $forgive;
`
When comment is OK or needs moderation, everything works as expected.

Comments

  • Check the value of your 'SA_Forgiving' option. 3 is not a valid error result. Positive errors come only from the plugin.
  • Hello,
    Thanks for your quick answer.

    var_dump($forgive) provides me the following information:
    string(1) "0"

    You can see the offending message here:
    http://www.hebergement-pro.org/zenphoto/
    You can try with the following message:
    anatrim furniture sex wedding

    I modified the source code to print the $forgive variable when the comment has to be rejected / moderated
  • Sorry, I guess you will have to tract the return value through the process. I've tested with the "none" filter and moderated works. That filter returns the constant "1".
  • Hello,

    I found the bug !

    functions.php, postComment(...), line 992:
    `$commentobj->setInModeration(2); //mark as not posted`

    As the return code of the SpamFilter is 0, This variable is not modified anymore in this file. So, we are getting back to functions-controller.php
    with the value "2".

    functions-controller.php, zp_handle_comment(...), line 184:
    `
    $comment_error = $commentadded->getInModeration();
    [... the value is 0, so it does not get in the if statement ...]
    $comment_error++;
    `
    So, right now, the $comment_error value is 3.

    controller.php:
    `$_zp_comment_error = zp_handle_comment();`

    $_zp_comment_error is used to determine the error message to send to the spammer.

    We have two ways to solve that bug:
    - in comment_form.php, getCommentErrors:
    `case 3: return gettext("Your comment failed the SPAM filter check.");`
    - modify functions.php, functions-controller to handle the case where a spam filter will return a 0 (the comment has to be dropped)

    Try and guess what I did :D

    Do you want me to fill a bug with this fix?
  • Yes, please. File a bug report.
  • Actually, no need for a ticket. Your fix is the correct one. I'll release the fix for tonight's build.
  • BTW, we will be happy to post your update to the Spamassassin plugin. It is just that the two of us have no means to test the module, so we removed it from the distribution.
  • Hello,
    That's exactly how I understood the changelog.
    There are some bugs remaining. When everything will be cleaned, I will provide you the source code.
    Right now, filtering works fine, Minor bugs are still present and need to be fixed, as it's not usable by final users.
    I will try to add the socket support.

    I hope I will have time to do it this week.
Sign In or Register to comment.