I just updated wordpress and akismet eveything is working fine except on the comments page the “check for spam button” returns the following error”
Warning: Invalid argument supplied for foreach() in blog/wp-content/plugins/akismet/akismet.php on line 722 Warning: Cannot modify header information - headers already sent by (output started at blog/wp-content/plugins/akismet/akismet.php:722) in blog/wp-includes/pluggable.php on line 770
I checked for the normal header issue and deleted an extra space from akisment.php in the plugin folder pluggable.php didn’t have extra spaces.
Any help to get this resolved would be great.
Looks like a bug I think. Only happens if you have no comments awaiting approval. There’s a piece of code where it checks
SELECT * FROM $wpdb->comments WHERE comment_approved = ‘0’
And then uses the results in a php foreach loop. I think when there are no query results then that is what causes the invalid argument.
Try unapproving a comment and seeing if you can “check for spam” then. (Mind you that the code would only check the unapproved comments, which I think is slightly odd because you would really be expecting it to check the entire queue.)
You could try hacking the code so it just says
$moderation = $wpdb->get_results( "SELECT * FROM $wpdb->comments ", ARRAY_A );
Which would force it to rescan the whole queue, but I have not regression tested it so I don’t know what effect that would have if it found spam results within already approved comments.
Thanks you are right, when i unapproved a comment and clicked the button it ran just fine.
I noted the url this time though when there are unapproved commentsthe url is
yet with all approved comments the url is
if i change noheader=false the header error goes away.
Is this a bug i should submit to wordpress or just let it be. Also where should i try hacking the code at?
The area I was mentioning to modify is in akismet.php around line 722, but, as I say, I’m not sure what the actual effect of doing that is, other than to make the error message go away. Really it needs a proper fix to modify the behaviour when the “recheck for spam” button is pressed on comments that are all approved.
Unfortunately I am not sure where to report the bug to – it’s not actually a WordPress issue, it’s an akismet issue. Previously they would have been reportable on wp-plugins.org but that has all changed now.
Thanks again for your help. I submitted this issue on akisment’s official site. asking them where the best place to get help for this would be.
Hopefully this will be resolved soon,
I’m having the same problem after updating to WordPress 2.6.1 and Aksimet 2.1.6. Not sure what to to….
I’m having this same problem, but I don’t understand the solution posted by mrmist. I have over 17,000 comments awaiting moderation, but I still get the error, so the problem for me is definitely not just happening when there are no comments awaiting approval.
Does anyone know how I can work around this error or deal with all this spam that’s already made it through before I got Akismet installed?
This has been resolved for me by keeping a current wp and akisment installation. i haven’t had this happen again it just happened that one time.
@gary king: for me yes it’s resolved but it looks like others still have problems from time to time. I don’t know what the best practices are on marking something solved but if it’s happening to others i don’t want to mark it resolved.
@ wfryer & zomigi: Is this happening with wp 2.7 and the latest version. Also zomigi there are a slue of other comment spam programs/plugins akisment was just first developed for wp by matt and is installed by default. I haven’t used any other but i know people who have. Another way to prevent spam is use a capatcha.
Hope this helps
I am now running 2.7.1. I no longer get any error, but when I click the check for spam button, it doesn’t identify any of the over 16,000 comments as spam, although they look just like the ones that it does catch as spam. So it still doesn’t appear to be working on old comments. Oh well!
@zomigi I’m not sure how the “check for spam” button works. This article suggest that you make sure you’re running the latest version of Akismet and that you may need to hit submit a few times. I also am wondering if it’s done on a per page basis. How did you get 16,000 spam comments? I haven’t got that with having my blog live for almost 2 years!
- The topic ‘check for spam header issue (akismet)’ is closed to new replies.