Modifying my-sites.php Error 500 Header

On PrimaryBlogger we used to take advantage of the blog list function from _access_denied_splash, in /wp-admin/includes/ms.php, to serve a modified version listing all users blogs and allowing them to create new ones from the page; due to problems that will be listed I had to create a custom popup to allow users to go to their blogs, some of which was discussed in my last post.

Firstly, we use Nginx, PHP-FPM & Varnish to serve our content and admin pages. Nginx, like other HTTP server software, allows you send customised error pages for certain headers, such as 404, 500 etc. I decided to make our error pages more user friendly, with contact details and other useful information that would let users either alert us to problems or let them fix them on their own – alleviating our support process a bit if any changes went wrong.

So, when we made the change to Nginx we started getting lots of emails stating that people couldn’t log into their blogs any more, receiving in its place an error 500 status page – obviously with our newly created custom error page. I fiddled round for ages disabling plugins and all the usual WordPress troubleshooting guff, eventually leading myself to believe it was the new 3.4 update that had possibly corrupted something. Nothing on Google pointed to anything obvious, but then I remembered the wp_die function usually sent an error 500 but with a modified output, allowing you to create normal pages but changing the error header.

Easy to fix by referencing; I added the below to the bottom of the _access_denied_splash, in /wp-admin/includes/ms.php.

$my_title = 'My Blogs › PrimaryBlogger';
wp_die( $output, $my_title, array('response' => 200) );

This changed the error code back to a normal 200 ok response, thus disabling my 500 error.

Leave a Reply

Your email address will not be published. Required fields are marked *