WordPress 500 Error when submitting a blank comment form under IIS7 and PHP5

I recently noticed an issue on this very blog and a couple i have hosted on this server when people just hit submit on the comment form without entering anything into the comment field- i would get a 500 server error back.

error_pagesI spent ages googling figuring it was some kind of config error on the server as it happened across all of the wordpress blogs on this server- I eventually found it wasn’t an error at all- The skins used across these blogs didn’t seem to validate the forms so it was falling back to wordpress which was returning an error like “Error: please type a comment.”- however IIS seemed to be intercepting this as a full error and rendering a 500 error- the solution was simple!  Turn on detailed error’s.  Obviously this isn’t good on a production box running dot net, but for PHP you can control the error reporting from within the php.ini file anyway, so this just makes sure IIS doesn’t add an additional layer of error filtering confusing matters.

Update: Thanks to Kanwaljeet Singla on the comments for pointing out a better fix for this as detailed on Kern Handa’s blog here.  This can basically be fixed easily by setting a web config entry to tell IIS to let errors pass through, like so;

<?xml version="1.0" encoding="UTF-8"?>
        <httpErrors existingResponse="PassThrough" />
  1. #1 by Kanwaljeet Singla on June 11, 2010 - 19:33

    Setting existingResponse=”PassThrough” is the recommended way to fix this. Check out http://bit.ly/15bhnL. In Win7 sp1, this will be fixed. With this fix, IIS won’t override errors coming out of PHP even when existingResponse is set to “Auto” which is the default value of this property.


  2. #2 by shawson on June 13, 2010 - 12:51

    Cheers for posting Kanwaljeet, that’s brilliant- I’ve updated the post!

(will not be published)