I get the following error in the logs whenever I manually mark a message as either spam or not spam:

Division by zero in /usr/local/share/drupal-4.6.3/modules/spam-2.0.10/spam.module on line 961.

It doesn't *seem* to be having any negative effects, but I can't be sure. I do know that the bayesian filter is a little wonky... it flagged a recent non-spam comment as spam with an 85% chance, and I have absolutely no idea what it triggered on; there didn't seem to be anything remotely spammy about it.

Comments

Zed Pobre’s picture

As an additional note, I'm running Drupal on Postgresql, which may be a contributing factor.

jeremy’s picture

Assigned: Unassigned » jeremy
Priority: Normal » Critical
Status: Active » Needs review

Please try this version of the module and let me know if the problem goes away.

You can see just the fix here.

It would be worth reviewing your tokens table to see if the values look sane. If they don't, or if you're not sure, I'd recommend dropping the table and recreating it in case there is bad data in there.

BTW: To determine why the module marked a given comment as spam, go to administer >> settings >> spam and at the bottom configure the module to Log "everything". On the next comment that is mis-marked, go to administer >> comments >> spam and click "view log" -- it will give you a token by token breakdown of how it came up with the spam probability.

Zed Pobre’s picture

The tokens table had a number of tokens with negative values for either number of spam or not-spam messages, so I dropped it and recreated it. The division by zero error seems to have gone away in 2.0.12pre.

Thanks.

jeremy’s picture

That reminds me, there's a second place I need to make that change. You should upgrade to this version or later, or your token table will get corrupted again. View the changes here.

BTW: The changes to spam_duplicate_filter() are unrelated, just another little bug I found recently.

Does everything else seem to be working for you in the spam module with PostgreSQL?

Zed Pobre’s picture

Your link is broken; it goes back to the version you put up a few days ago. I just manually entered the changes from the posted diff, though, and we'll see how it goes. I *do* have negative numbers again. I'm just going to set all of the negative values to zero, rather than lose all the data this time, unless you think that's a very bad idea.

I am having a new problem, though, and a much more serious one. Ever since I updated to the 2.0.12pre a few days ago, the spam.module has stopped taking action on trackbacks. I checked the configuration, and it is still set to do so. I will have to revert to 2.0.10 if the source of that problem can't be found soon; I'm already being inundated with spam, and I even have a large number of IPs already filtered via iptables, so I'm stopping a few hundred attempts a day before it even hits the webserver.

If you have a version of your comment.module patch against the 2.6.3 version, that would be great.

jeremy’s picture

> I'm just going to set all of the negative values to zero, rather than lose
> all the data this time, unless you think that's a very bad idea.

Keep an eye on it and let me know how it goes. Personally, I would drop the tokens table and start over, as the data is already corrupt. They Bayesian filter is intended as a last-chance effort to catch spam, it's the other mechanisms that tend to catch the bulk of spam.

> I am having a new problem, though, and a much more serious one. Ever since
> I updated to the 2.0.12pre a few days ago, the spam.module has stopped
> taking action on trackbacks.

You need to apply the patch found here. The spam module API changed, unfortunately this change hasn't yet been merged into the trackback module.

Zed Pobre’s picture

That worked, and spam.module is now once again blocking trackbacks properly. I've posted another bug with the tokens table, but there weren't that many negative values to correct, and I think a few off-by-one (or at most, off-by-four) calculations won't create too much trouble.

Zed Pobre’s picture

Whoops. I'm getting fresh division by zero errors, possibly related to a failure to detect existing tokens:

Division by zero in /usr/local/share/drupal-4.6.3/modules/spam/spam.module on line 963.
query: INSERT INTO spam_tokens (token, spam, notspam, probability, last) VALUES('credit', 1, 0, 99, 1127333393) in /usr/local/share/drupal-4.6.3/includes/database.pgsql.inc on line 62.
pg_query(): Query failed: ERROR: duplicate key violates unique constraint "spam_tokens_token_key" in /usr/local/share/drupal-4.6.3/includes/database.pgsql.inc on line 45.
Zed Pobre’s picture

Disregard, sorry.

That last was a side-effect of a change I made to trackback.module while testing a corrected query string.

jeremy’s picture

Status: Needs review » Reviewed & tested by the community

Updating status, will be marked fixed when 2.0.12 is released.

jeremy’s picture

Status: Reviewed & tested by the community » Fixed

Fixed in 2.0.12.

Anonymous’s picture

Status: Fixed » Closed (fixed)