Posted on June 25, 2009
Filed Under weblogs | Comments Off on No Mr Bond, I Expect You To wp_die()!
After my argument with Alex King the other day where he defended his use of a “wp_die()” call from his WordPress plugin as being a completely appropriate thing for a plugin author to do, I got curious. I have 27 plugins on this blog, 12 active and 15 inactive. I deleted the two I had installed that Alex authored so they are not included in this count.
I did a grep on wp_die from my wp-content/plugins directory. I found 6 occurrences of it – 5 from Tantan Spam and 1 from WP DB Backup. Tantan spam is using it as the mechanism of comment spam fighting. When it has determined that the incoming comment has not proved to be from a legitimate commenter it uses wp_die to bail and not post the comment. WP DB Backup use it in the error handler when the type is “fatal”, which includes things like lacking permissions to write files or trying to download backups when not an admin user and such.
So, out of my 27 plugins only 2 use it at all and both of those are in specific transactions. I stand by my point that the use of wp_die for any plugin on an ordinary configuration error is wildly inappropriate. Because the routine that tried to load popularity contest’s configuration was ultimately called on every page load, this completely killed every single page of my blog. Alex continues to defend his code as standard procedure and the situation that I and others were in as “whacked out config” . It was the config his previous version of the plugin set up and ran with for over a year. I’m not really incensed about the error so much as the not caring, the blaming of us, refusing to accept that his logic was bad and his handling was worse, etc. Crowd Favorite is not currently my favorite, that’s for sure.
PS – All of this had me wondering exactly how hard it is to write WordPress plugins, so I fiddled with the Digest Post one to add admin pages and to get and write its options from the database. It’s not too difficult and is kind of fun. I emailed the author of that plugin and offered to either send him patches or take over as maintainer of it. We shall see.