A little more investigation—MySQL seems to think that 0 and ‘0’ are the same value:
mysql> select 0=0;
+-----+
| 0=0 |
+-----+
| 1 |
+-----+
1 row in set (0.00 sec)
mysql> select 0='0';
+-------+
| 0='0' |
+-------+
| 1 |
+-------+
1 row in set (0.00 sec)
mysql> select 0=1;
+-----+
| 0=1 |
+-----+
| 0 |
+-----+
1 row in set (0.00 sec)
It also thinks that there are only three possible values for comment_approved: 0, 1, and spam.
mysql> select distinct(comment_approved) from wp_comments;
+------------------+
| comment_approved |
+------------------+
| 0 |
| 1 |
| spam |
+------------------+
3 rows in set (0.00 sec)
How many do I have of each?
mysql> select count(comment_approved), comment_approved from wp_comments group by comment_approved ;
+-------------------------+------------------+
| count(comment_approved) | comment_approved |
+-------------------------+------------------+
| 1 | 0 |
| 179591 | 1 |
| 452 | spam |
+-------------------------+------------------+
3 rows in set (0.41 sec)
mysql> select count(*) from wp_comments where comment_approved = 'spam';
+----------+
| count(*) |
+----------+
| 452 |
+----------+
1 row in set (0.00 sec)
mysql> select count(*) from wp_comments where comment_approved ='0';
+----------+
| count(*) |
+----------+
| 1 |
+----------+
1 row in set (0.02 sec)
mysql> select count(*) from wp_comments where comment_approved = 0;
+----------+
| count(*) |
+----------+
| 453 |
+----------+
1 row in set (0.16 sec)
I don’t get it. Why is 0 equal to ‘0’, and why does ‘spam’ also appear to be equal to 0?
According to mysql --version
, I’m using mysql Ver 14.12 Distrib 5.0.22, for pc-linux-gnu (i486) using readline 5.1
I get the same errors with the most recent release of akismet as well and reverted back to the previous version until there is a solution for this.
Trent
i had the same problem, i tryied many things at least…
i earese it
then
upload the akismet comes with the wordpress 2.6.1
and activate it , lala it works 🙂
anyway
new version 2.1.7 already relaesed 🙂
and akismet 2.1.7 make same problem again.
here is the solution=
delete akismet and upload the akismet comes with the wordpress 2.6.1 in the content>plugin>
use that one , it works 🙂
I don’t get it. Why is 0 equal to ‘0’, and why does ‘spam’ also appear to be equal to 0?
Non-strict typing.
When you compare 0 to ‘0’, SQL first converts the numeric to its string equivalent. Since the string equivalent of the value 0 is ‘0’, and ‘0’ = ‘0’, 0 thus equals ‘0’.
When you compare 0 to 0, they are like types (numeric), and no type conversion is necessary.
When you compare ‘spam’ to 0, SQL converts the string ‘spam’ to its numeric value – 0. Since 0 = 0, the statement is true.
Thus, the only reliable way to compare values in a field with mixed string and numeric types is to always compare against the string literal, not the numeric values.
HELP!
I followed this thread and decided I needed to swap out my 2.1.7 Akismet for the one that comes with WP 2.6.1. So, I started by de-activating it, then deleting it from the server, then uploading the “correct” version. However, now I have no option to enable Akismet! 🙁
I’ve checked the obvious – it’s in the correct directory and seems to have the same properties as the other plugins!
Any suggestions?
Many thanks,
-John.
I wasn’t able to delete all on the spam either – i had to downgrade to the previous version and then it started working again..
Same issue here…haven’t tried to fix it, perhaps an update will make it work?
The Delete All issue is unrelated to the value of zero.
Ryan fixed it: http://plugins.trac.wordpress.org/changeset/62048/
You just need to update your Akismet plugin to 2.1.8.
latest version is crap. anyway i can downgrade to previous version?
edit: I have 2.1.7, i guess I need to upgrade.
Somehow wordpress isnt showing I need to update it
Thanks SO much for fixing this, I’ve had this problem for the past 5 days and the 2.1.8 version resolves it for me at last!