[wp-hackers] Personalizing db down WordPress errors
dougal at gunters.org
Fri Aug 3 18:39:52 GMT 2007
Peter Westwood wrote:
> Chetan Kunte wrote:
> > I came across this yesterday:
> > http://bitworking.org/news/224/One-of-these-things-is-not-like-the-other
> > On self-hosted sites, this is a familiar sight, and it is a bit
> > obvious to site owners. But not so for visitors, particularly when
> > they see a WordPress error message on screen [as seen in the link
> > above].
> > Personalizing this "database-down" error message using the active
> > Wordpress theme would be a better idea [and should be in the core].
> > What do you'all think?
> If the db is down then you don't know what the active theme is ( or for
> that matter any other of the options values).
> The best that can be done is providing a single plugin-in mechanism for
> replacing the page e.g. is a file in wp-content called db-error.php
> exists then include that rather than use the normal error output handler.
I had an idea I was going to suggest, but I couldn't actually get it to
work, and it would probably never make it into core anyhow, because of
The basic idea I had was that a template (or possibly a plugin) could
put a new rewrite rule into the .htaccess file, defining an
ErrorDocument directive for a custom error page.
1) Wouldn't work for sites that don't use Apache and/or mod_rewrite.
2) In addition, the ErrorDocument directive requires that
"AllowOverride FileInfo" is active, as well. There may be server setups
where this isn't the case, and the user has no control over it.
3) Requires us to modify WordPress core: In wp-settings.php, we'd have
shift some includes around (need functions.php, classes.php, and
plugin.php to come before the wp-db.php include). In wp-db.php, we need
to modify the bail() function to emit an HTTP 500 status code (which is
why we have to shuffle the includes around). WE SHOULD PROBABLY DO THIS
ANYWAYS. Emitting the correct HTTP status when we encounter this type of
error would be a Good Thing.
And lastly, even when I tried setting all that up, it still wouldn't
work. I'm not sure why -- I verified that Apache was serving a 500
status code, but my custom ErrorDocument was not served to me, I still
got the standard WP error.
Maybe someone with more time to work on it can come up with something
along these lines that works?
Dougal Campbell <dougal at gunters.org <mailto:dougal at gunters.org>>
More information about the wp-hackers