Mass Delete for 1.5

Back in September of 2004 I released a plugin that allowed you to delete large amounts of spam with one click.

Some backstory

Basically one afternoon I was hit with a wave of spam that resulted in 1500+ comments awaiting moderation that were all spam.  That was not a fun prospect, deleting all of those comments via the admin UI.  So I took a trip to the terminal and issued one command, which wiped them all out.

So taking that experience I created a plugin that allowed you to delete comments by author, IP, email or URI.  Now fast forward to WordPress 1.5.  1.5 has some wonderful toosl to help you combat spam built in, a blacklist feature, moderation by keywords and so on.  At first I was stoked at how well these tools were working, I didn't see any real waves of spam hitting my site, I was assuming that 1.5 was sending all that evil to /dev/null/ like a good little monkey.

I however, was very wrong.

Apparently the DEVs decided that what should happen is that anything that is considered spam will be flagged as such: 'spam' and kept in the comments table in all our databases.  I still fail to see the usefullness of this, but that was not my call.  The point is that I was in my DB mucking around, as I am want to do, and found that I had 1500+ "spam" comments just hanging around in my comments table, with no way to interact with them from within WP.  Now for me, that really isn't a big deal, I just fire up the old terminal, or open phpMyAdmin and delete them that way.  For the normal user though, that is another story.

Enter Spam Nuke

spam nuker!

So I being the good samaritan I am, raised a feature request bug about this, and was basically told that you should just issue the "DELETE from wp_comments WHERE comment_approved = 'spam'"; which my friends is crap.  The normal user who cares about the size of thier DB should be able to easily and quickly get rid of that chaff from within WordPress.

Well now you can.

I had been meaning to update Mass Delete for 1.5 for some time.  This answer from the DEVs gave me the impetus I needed to get it done.  This new version serves two purposes:

Getting to the features

You can still delete groups of spam as you did originally, only now Mass Delete only deletes from comments flagged as spam, when you are successful you see this message:

nuke some

The new feature is Mass Nuke, with one click you can nuke every comment in your table that is flagged as spam, when run successfully you see this message:

nuke em all!

Not really much to it, really.  Once the plugin is activated you can find it in the Manage submenu, there will be a selection labeled Spam at the end.

Here is the file you need cjd_delete.zip.  Enjoy and let me know if you find any bugs, or have any comments.

Tagged:

  1. personal avatar Mike
    Stroll on over and visit Mike
    March 1, 2007

    Best. Plugin. EVER.

    Seriously, it found 304 messages marked as spam in the database for one of the WordPress installations I maintain. I love it.

  2. personal avatar Indranil
    Stroll on over and visit Indranil
    March 1, 2007

    And to think that I was overjoyed to see a 'spam' marker for comments!
    Well, immense thanks for the plug.

  3. personal avatar Dougal Campbell
    Stroll on over and visit Dougal Campbell
    March 1, 2007

    We flag them as spam rather than outright deleting them in order to give plugin authors (such as yourself) something to keep you busy ;)

    No, seriously. I think we will eventually add something (unobtrusive) in the admin interface to let you delete them. But there is value in saving them. First of all, because some small fraction of users might want to review the data for finding false-positives. And also because the data can be used for Bayesian analysis.

  4. personal avatar kartooner
    Stroll on over and visit kartooner
    March 1, 2007

    Thanks Chris. I can't tell you how long I've been looking for a plugin like this. I appreciate your effort. :)

    If you have a sliver of time, could you email me? I've got an idea for a simple Wordpress plugin and believe me, if I knew how to write a plugin (yeah, I've read the tutorial floating around the net) I'd do it myself.

  5. personal avatar Aaron
    Stroll on over and visit Aaron
    March 1, 2007

    You are a genius. Ill be trying that plugin real soon. From what I have read so far is that, this is the most awesome spam deletion tool! Great work man! Oh, and congratulations again on the parenthood!

  6. personal avatar Michele
    Stroll on over and visit Michele
    March 1, 2007

    Another extremely useful plugin. Not that running a SQL query is big problem for me, but I'm sure it is for many...and well, this way's easier.

    Thanks for being the good samaritan you are! :D

  7. personal avatar Shawn Grimes
    Stroll on over and visit Shawn Grimes
    March 1, 2007

    Great update Chris. I had forgotten about all the spam I had in my table from moderation. And now they are all gone.

    All spam Nuked! Rowr! I love it!

  8. personal avatar Svein Kåre Gunnarson
    Stroll on over and visit Svein Kåre Gunnarson
    March 1, 2007

    What a nice plugin - works like a charm. And here I had thought that the messages I marked as spam were deleted completely. Well - not only have you made me aware of that - you also made it easy for me to get rid of'em. Thanks! :)

  9. personal avatar Matt
    Stroll on over and visit Matt
    March 1, 2007
    The end user should never have to go to the DB or phpMyAdmin to do something.

    Well the answer to the bug was very targetted, because users would never know the spam existed unless they used this plugin (which I wouldn't advise) or they looked at the database. We'll never be able to have a decent bayesian filter unless we have a good corpus of ham AND spam comments.

  10. personal avatar Chris J. Davis
    Stroll on over and visit Chris J. Davis
    March 1, 2007

    Dougal,

    We flag them as spam rather than outright deleting them in order to give plugin authors (such as yourself) something to keep you busy ;)
    I appreciate you guys looking out for me like this, brings a tear to my eye...
    No, seriously. I think we will eventually add something (unobtrusive) in the admin interface to let you delete them. But there is value in saving them. First of all, because some small fraction of users might want to review the data for finding false-positives. And also because the data can be used for Bayesian analysis.

    I agree that there is some value to saving the comments flagged as spam, my point was that the answer I got was crap, it took me 10 minutes to adapt some of my old code to do this, I assume it would have taken you who are code-gods much less time.

    The end user should never have to go to the DB or phpMyAdmin to do something. And for the record had I not been cleaning out my table via the terminal until I had this done, I would have around 3000 spam comments in my DB, and that is only since I installed whatever build of 1.5 that incorporated this, think about had I gone a year without checking my DB.

    Lets just say I have been running like this for 2 months. 3,000 commments every two months becomes 3,000 X 6 = 18,000 comments that are spam. And I would have never known. This is unnaceptable from an end user standpoint.

    That was my point, this should have been provided by the core, not a plugin, but what do I know, right? ;)

  11. personal avatar seriocomic
    Stroll on over and visit seriocomic
    March 1, 2007
    ...users would never know the spam existed unless they used this plugin (which I wouldn’t advise) or they looked at the database. We’ll never be able to have a decent bayesian filter unless we have a good corpus of ham AND spam comments.

    ooh...I LOVE being an unknowing guinea-pig. Thanks Chris for your fix.

  12. personal avatar Matt
    Stroll on over and visit Matt
    March 1, 2007

    Also, I may not agree with the plugins you make but I'll fight to the death for your ability to make them. :)

  13. personal avatar Chris J. Davis
    Stroll on over and visit Chris J. Davis
    March 1, 2007

    Matt,

    Well the answer to the bug was very targetted, because users would never know the spam existed unless they used this plugin (which I wouldn’t advise) or they looked at the database. We’ll never be able to have a decent bayesian filter unless we have a good corpus of ham AND spam comments.
    Agreed, I just don't think that the way you chose to implement this is the best way. Period. But again, that is my opinion and I am able to fix what I see as a hole on my own, aint open source grand?
    Also, I may not agree with the plugins you make but I’ll fight to the death for your ability to make them. :)

    And that my friend is why I am still here, and why I work with you to hoepfully make this a product that surpasses all expectations. I don't have a problem with the project lead not agreeing with me when I rant. ;)

    Oh and get a freakin gravatar!

  14. personal avatar Greg
    Stroll on over and visit Greg
    March 1, 2007

    Thank you Chris, thank you thank you thank you!

    It's just what I've been looking for

  15. personal avatar khaled
    Stroll on over and visit khaled
    March 1, 2007

    Yeah Matt sort yourself out, you lazy bum :). The power of open source is all too great.

  16. personal avatar kyte
    Stroll on over and visit kyte
    March 1, 2007

    I must be the first person for it not to work :( Installation, no problem; visible in the plugins management area, no problem; clicking on the button to "nuke 'em all" sends it off to do its work. But the spam is still there. all 439 instances. :( I am guessing its a server config issue but because I have no clue regarding those things (and no control over the server config in any case) i am stumped. Everything *looks* as if its working but the spam doesnt get nuked.

    any clues at all?

  17. personal avatar Jonas Rabbe
    Stroll on over and visit Jonas Rabbe
    March 1, 2007

    Matt,

    We’ll never be able to have a decent bayesian filter unless we have a good corpus of ham AND spam comments.

    Well, why don't you just have a "delete spam comments silently" checkbox in the admin interface. If the box was checked the spams would be deleted, if it was unchecked the current behavior would take place. This would allow the user to decide.

  18. personal avatar Martin
    Stroll on over and visit Martin
    March 1, 2007

    I never new all the spam comments stayed in the DB once marked as Spam, so this plugin is a revaltion! Installed and i had 394 Spam comments! Brill plugin. :)

  19. personal avatar Niklas
    Stroll on over and visit Niklas
    March 1, 2007

    Thanks! Your plug-in works wonders.

  20. personal avatar Chris J. Davis
    Stroll on over and visit Chris J. Davis
    March 1, 2007

    Thanks for the quick response.

    I can admit the validity of some of your points, much better stated this time around!

    I am stil l not convinced on the usefullness of a large spam/ham farm as opposed to a small, targeted one.

    But time will tell, and I am willing to wait to find out.

  21. personal avatar Mark J
    Stroll on over and visit Mark J
    March 1, 2007

    The IP information is likely worthless, but the URIs are valuable, as are the keywords they use. Spam Karma 2 is going to use that information in some way. It is already useful in Spam Karma 1 (with a one line modification) to save comments as "spam" instead of dropping them entirely, because if you see a legit comment in your SK digest, it can easily be restored (using ColdForged's plugin for viewing and editing spam comments).

    My use of the word "yahoo" wasn't meant to refer to people who have massive quantities of spam in their database and want to trim it down... I was more referring to a casual user who might see a "delete spam instead of saving it" option and think "heavens, I don't want to save spam!" and thus any benefit of being able to take past spam into consideration would be severely muted because of the ease with which yahoo--er, people, could disable it.

    Also, I can see how a buildup of spam could be a problem in the long term (or short term if you have a massively popular site). That is a problem that needs to be addressed. There should be a limit to how many spams are stored in the database, or things will eventually get out of hand. I think I'll suggest that in Mosquito.

    No snarkiness taken. And I apologize if my first comment implied that people don't have a right to the contents of their database. I don't think that at all. You absolutely have a right to it. I just think that if you put a "delete spam instead of saving it" option in there, people will opt to can the spam instead of saving it for possible future benefit. I think the best compromise is to limit the number of comments so that your concerns about database bloat are addressed, but there is enough of a spam base for anti-spam plugins to use to fight future spam.

  22. personal avatar Chris J. Davis
    Stroll on over and visit Chris J. Davis
    March 1, 2007

    I am not even sure where to begin Mark.

    I am not sure what amazes me more, that you think that having a spam farm full of information that is most likely spoofed, and therefore of no real value is good, or that I and all the other users, what did you call them... "yahoos" that was it, out there have no right to the contents of our databases.

    And I am not sure what kind of traffic you are generating, but I assure you that the spam comments that would be "hanging out" in my DB are like stinking rats, since I would have tens of thousands at the end of even a few months. That is unacceptable.

    And I appreciate you giving me permission to delete the spam in my db, thanks for that. *edit* I don't want to be snarky, that is not my intent, I do appreciate your comment I just don't see the logic.

  23. personal avatar Mark J
    Stroll on over and visit Mark J
    March 1, 2007

    I'm rather confused as to what problem this is solving. This isn't like a rat who dies in your wall and starts to stink after a few days... spam sitting hidden in your database does you no harm, and one day (rather soon, actually), it will be used to better identify blog spam. It seems to me that this appeals to the obsessive compulsive types who, now that they know spam is lurking in their database, are losing sleep. "Everywhere I turn, I can't see them, but I know they're there... I feel them watching me! Ahhhh!"

    As to providing an option... and forgive me for going all Socialist on you... sometimes things need to be done in order to benefit the largest possible number of users. If you want to purge the invisible spam, more power to you, but it shouldn't be included in the core so that any yahoo can limit their spam-fighting abilities with a single click.

    Also, I may not agree with the plugins you make but I’ll fight to the death for your ability to make them.

    What he said. :-)

  24. personal avatar Nat
    Stroll on over and visit Nat
    March 1, 2007

    sweeet it worked for me :)

  25. personal avatar andrena
    Stroll on over and visit andrena
    March 1, 2007

    Thank you so much! Until I stumbled upon your site, I didn't have a clue that all the spam was in my database (duh!!!) Thank you again! :-)

  26. personal avatar patrick
    Stroll on over and visit patrick
    March 1, 2007

    Worked great; thanks!

  27. personal avatar Micah
    Stroll on over and visit Micah
    March 1, 2007

    This is the single best WP plug-in I've ever downloaded. Thanks for doing this.

  28. personal avatar pericat
    Stroll on over and visit pericat
    March 1, 2007

    Lovely! And much less of a chore than remembering to ssh out to my host and do SQL things.

    Thanks for this, as well as your many other fine contributions that make my life easier.

  29. personal avatar Chris J. Davis
    Stroll on over and visit Chris J. Davis
    March 1, 2007

    No, that should read as it does,

    "Be warned this is undoable."

    And as for the sorting, I am fairly confident that a valid commenter will be showing up in singles, not in multiples.

    But I have been investigating how to modify the code to allow for differing sorts.

  30. personal avatar Anton Sherwood
    Stroll on over and visit Anton Sherwood
    March 1, 2007

    There appears to be a small error in the text:
    "Be warned this is [missing word?] undoable ..."

  31. personal avatar Anton Sherwood
    Stroll on over and visit Anton Sherwood
    March 1, 2007

    Or possibly: tr '\r' '\n' <cjd_delete.php >cjd_delete.php.unix; mv cjd_delete.php.unix cjd_delete.php

  32. personal avatar Anton Sherwood
    Stroll on over and visit Anton Sherwood
    March 1, 2007

    Thanks!

    The Unspam menu would be easier to use if it could be sorted by a column other than IP.

  33. personal avatar Tim Hardy
    Stroll on over and visit Tim Hardy
    March 1, 2007

    Great plug-in, thank you! Worth it for the "unmark as spam" option alone.

    This didn't work out of the box for me when I unzipped it under linux. The "Enable plugins" screen became garbled with the contents of the raw php file. I'm guessing this is because you developed this on a Mac which handles endline characters differently.

    If anyone other linux user is having the same problem, the following converts the code to unix format:tr '\r' '\n' cjd_delete.php.unix && mv cjd_delete.php.unix cjd_delete.php

    Hope this helps a few more linux newbies enjoy the fruits of your work!

  34. personal avatar Tim Hardy
    Stroll on over and visit Tim Hardy
    March 1, 2007

    Anton is correct - apologies for the typo above in which I've somehow missed out a vital chunk of the command sequence. Thanks for correcting this.

  35. personal avatar Anton Sherwood
    Stroll on over and visit Anton Sherwood
    March 1, 2007

    Oh. How is it undoable? (And why the warning?)

    Yes, a valid commenter is likely to be unique, and thus harder to spot if the sorting is effectively random. Each dummy domain tends to occupy several rows of the table with different IPs; the false positive does not stand out.

    If the table were sorted on the name, it would be easier to find the one whose name is not some variant of "poker". If it were sorted on the URL, it would be easier to find the one that is not in a "dummy domain of the day".

  36. personal avatar Jo
    Stroll on over and visit Jo
    March 1, 2007

    Excellent! Thank you so much - had no idea those peskie lumps of spam were still hanging around

    All nuked!!

    :)

  37. personal avatar Logan
    Stroll on over and visit Logan
    March 1, 2007

    Excellent plugin. I didn't even know that those little spam-spawn were still in my database. Thanks!

  38. personal avatar Michael Sarver
    Stroll on over and visit Michael Sarver
    March 1, 2007

    Much like many of the others said, I had no idea that when I marked a comment as "spam" it was still chillin' in my DB. Thanks for the plug-in! I like order...

  39. personal avatar Oli
    Stroll on over and visit Oli
    March 1, 2007

    3333 spam comments in my db counts PHPadmin. One click with ur great Plugin and they all gone to nirvana.
    Thx a lot from a german user

  40. personal avatar Static Brain
    Stroll on over and visit Static Brain
    March 1, 2007

    Very handy little tool. Thanks for it. I hate spam and any invention to make it go away easier is dearly loved. :-)

  41. personal avatar Natasha
    Stroll on over and visit Natasha
    March 1, 2007

    Wow! I've just installed this. I've just recently started getting stupid spam comments from online poker and all that shiznay, and phpadmin is a bit screwwy on my computer. Thank you for making this, I'm a bit of a newbie, so this is UBERhelpful!

  42. personal avatar Jonathan
    Stroll on over and visit Jonathan
    March 1, 2007

    I take it this works OK with Wordpress 2.0.x? I hope so as I've just nuked 45 spam comments with it! I really don't want those cluttering up my database. Thanks for the plugin.

  43. personal avatar Andy
    Stroll on over and visit Andy
    March 1, 2007

    I just wanted to say thank you for a brilliant plugin. Effective, simple, easy to install and make use of.

  44. personal avatar Whitesox
    Stroll on over and visit Whitesox
    March 1, 2007

    Absolutely gorgeous plugin......

  45. personal avatar Gloups
    Stroll on over and visit Gloups
    March 1, 2007

    Thank you for this plugin. I'm sure it will help me !!

    (Sorry for my bad english : I'm french :-p)

  46. personal avatar bill
    Stroll on over and visit bill
    March 1, 2007

    I keep getting this error when trying to delete all spam comments:

    Cannot load cjd_delete.php

  47. personal avatar Jamie
    Stroll on over and visit Jamie
    March 5, 2007

    Great tool - I also has no idea that they left the comments in the db, I assumed they sent a short id or something to some spam database somewhere and then deleted it. I too do not understand why they would leave it in the db withoout giving the user an option to delete it as well. Thanks again!

  48. personal avatar Joe
    Stroll on over and visit Joe
    November 18, 2007

    I have a blog with 30,000+ spam comments. When I click on the spam item in the manage toolbar, the connection times out.

    I'm guessing this is probably because of all spam. Is there a setting somewhere that I can change so it doesn't time out, either on my browser, or on the server (I have root access).

  49. personal avatar Cori
    Stroll on over and visit Cori
    April 18, 2008

    Worked like a charm on 5762 spams ... plugged into WP 2.5 perfectly. Rowr indeed!

  50. personal avatar Mike
    Stroll on over and visit Mike
    June 8, 2008

    Thanks a lot for this saviour, Chris. Plugged into WP 2.5.1 perfectly and deleted all the spam that was accumulated in a flash.

Pingbacks & Trackbacks

  1. . . . muttered the ogre » items from elsewhere » [...] der: race — Anton @ 21:42 Ron Paul’s remarks on the war, to the House useful spam-handling plugin for WordPress 1.5 a gag about clashing jargons Sheldon Richma [...]
  2. MacManX.com » Blog Archive » Active Plugins » [...] m any popular search engine. Search Pages, to allow pages to be searched as well as posts. Spam Nuker, to manage spam deleted by WordPress’ default anti-spam tools. Translator, [...]
  3. ChapterZero » Further notes on spamming » [...] Hmmm… it seems WP doesn’t delete the comments that you mark as spam from the moderation queue; it simply marks them in the database and doesn’t display them, maybe as a precursor for using them to generate anti-spam software or dbs. Now I know that, seems like I have some db cleaning to do. There’s even a plug-in for this. [...]
  4. Writing Desk of The Scribe » Three hours later… » [...] And there’s more…I found a neat little plugin called Spam Nuke. It seems that when we delete a comment as spam, we’re not actually deleting it…it’s being kept in the comments table in our databases. Interestingly enough, when I installed this little plugin I discovered 1833 tucked away in a dark corner. They have since been “nuked”. In light of all this new armour, I’ve turned off moderation. I hope I don’t live to regret that. [...]
  5. fussychicken.com » I got an email the other day… » [...] But then the bandwidth messages started coming, and after looking at the logs, I learned a new phrase: “referer spam.” Online poker and prescription meds were hitting me every couple of minutes. Their goal is to get a link embedded in as many databases as they can, increasing their rankings in search engines. Because of Hashcash, they weren’t making it into the database (CJD Spam Nuke keeps track of that), but were still showing up in the logs, meaning they were eating up my bandwidth. [...]
  6. prince-of-darkness.org » Blog Archiv » Es gibt Neuigkeiten » [...] Außerdem sind ein paar neue Plugins installiert worden bzw. ein paar Plugins gelöscht worden. Die neuen Plugins heißen Bad Behavior, Spam Nuker, Dofollow und Google Sitemaps. [...]
  7. Layman’s Place » Defeating Spammers » [...] And there’s more…I found a neat little plugin called Spam Nuke. It seems that when we delete a comment as spam, we’re not actually deleting it…it’s being kept in the comments table in our databases. Interestingly enough, when I installed this little plugin (on my main site) I discovered 1833 tucked away in a dark corner. They have since been “nuked”. [...]
  8. …but it’s dirty! » Blog Archive » Pluging in even more plugins… » [...] 1) Mass Delete 1.5 (AKA “Spam Nuker”) [...]
  9. Webbericht » [...] Leider werden als Spam gekennzeichnete Eintr
  10. The Crime in your Coffee » Blog Archive » Spam Bots ausgeschlossen » [...] Apropos Spam und Wordpress. Moderierte Kommentare können bekanntlich mit der Option “mark as spam” als Spam markiert werden. Wer jedoch denkt, damit wird eine Art Blacklist gefüttert, mit der ähnliche Kommentare zukünftig unterbunden werden, liegt falsch. Die Funktion markiert diese Kommentare lediglich als Spam und speichert sie; mit dem Ergebnis, dass die MySQL-Datenbank langsam zumüllt. Also ziemlich sinnlos, zumal man die Spam-markierten Kommentare über Wordpress nicht mehr löschen kann. Das geht nur direkt in der Datenbank über phpMyAdmin oder komfortabler über das Wordpress-Plugin Mass Delete.   [link] [...]
  11. ThoSch:Blog » Blog Archiv » Spam-Problem gelöst (?) » [...] Die eingehenden Kommentare werden in zwei getrennten Listen für durchgelassene Kommentare und Spam aufgeführt. Hier ist neben den allgemeinen Angaben (Datum, Zeit, Absender, Bezugsartikel und Anrisstext) auch die Filterergebnisses, die zur Übernahme oder Abweisung geführt haben protokolliert (wichtig für ggf. notwendiges Feintuning). In der Übersicht mit dem (vermeintlichen) Spam kann man einzelne Kommentare auch recovern. Hierüber kann man auch Kommentare recovern, die man manuell über die normale Kommentarübersicht von WordPress als Spam markiert hat (geht wohl sonst nur mit Plugins wie Spam Nuker). Täglich wird eine Reportmail mit den abgewiesenen Kommentaren erstellt. [...]
  12. The K-log » Blog Archive » ok, so maybe not zestfully clean » [...] fortunately, i remembered talk of a spam annihilation plugin from when i was first looking into the problem, and i went and snagged it, and in a few short minutes i was greeted with: [...]
  13. Aux grands maux les grands remèdes at Gloups Blog » [...] - Et pour terminer, le plugin Mass Delete, je l’espère, m’aidera
  14. molleman.ch » [...] In den letzten Tagen machten mir die unzähligen Spam’s in meinen Blogs zu schaffen. Tausende von undurchsichtigen Mails beschäftigen mich fast Tag und Nacht. Auf der Suche nach einem geeignetem Spam Programm bin ich nun fündig geworden. Das WP Plugin habe ich installiert und die ‘falschen’ Mails bleiben aus. Und so funktionierts: [...]
  15. Spam?! Bring It On! at Web2r.co.uk » [...] So i post something, and my inbox is flooded with spam comments, which is very irritating so i did a Google to find out how to combat this annoyance, it turns out that someone has created a plugin for wordpress called Mass Delete its a terrific plugin and one every WP user should have installed. [...]
  16. WP - Mass Spam Nuke German (Plugin) - bueltge.de [by:ltge.de] » [...] Das original Plugin findet ihr bei Chris J. Davis. [...]

Leave a Reply


Speaking

Buy my book!

Blog Design Solutions