Dumb Things are Happening with Comments

I get a lot of spam comments on the blog here. You don’t see them, because I mark them as spam, a few hundred every week. They’re roughly uniformly distributed across all my posts. If fewer posts are open, I get fewer comments. So I want to minimize the number of comments I have to deal with.

I’m trying to use Mark Kenny’s Extended Comment Options plugin to automatically close comments on old posts. I used this plugin a long time ago, and it was great. But now, in WP 2.6, it seems to do exactly the inverse of what it says on the box: it closes my most recent posts and opens the oldest ones.

I don’t understand. Isn’t this just
UPDATE `wp_posts` SET `comment_status` = 'closed' WHERE `ID` IN (SELECT `ID` FROM `wp_posts` WHERE `post_status` = 'publish' AND `post_type` = 'post' ORDER BY `post_date_gmt` DESC) LIMIT 0,10

(Okay, it’s not quite that simple, because MySQL doesn’t do ORDER BY or LIMIT in subqueries… But it’s close! Temporary table?)

Has anybody got a good solution to this, better than a cron job to run that query?

Meanwhile, apologies to everyone who wanted to comment but couldn’t.

3 Responses to “Dumb Things are Happening with Comments”

  1. how about…

    BEGIN;
    DROP TABLE IF EXISTS `temp123`;
    CREATE TEMPORARY TABLE `temp123` (`id` INT);
    DELETE FROM `temp123`;
    INSERT INTO `temp123` SELECT `ID` FROM `wp_zw50dp_posts` WHERE `post_status` = 'publish' AND `post_type` = 'post' ORDER BY `post_date_gmt` DESC LIMIT 0,10;
    UPDATE `wp_zw50dp_posts` SET comment_status = 'closed';
    UPDATE `wp_zw50dp_posts` SET comment_status = 'open' WHERE `ID` in (SELECT `id` FROM `temp123`);
    DROP TABLE `temp123`;
    COMMIT;
  2. Scott Perry says:

    how about… use Akismet?

    I’m using it on my blog, and it’s had no false positives, no false negatives, and flagged 8 comments as possible spam (they were spam).

    most spam comments on blogs are blatantly obvious, even the world’s dumbest filter could catch them.

  3. @Scott: Yeah, but I don’t like sending my comments to a web service. Bit unsettling.

    Today I got _one_ spam comment. All right. This is better.