[wp-testers] Suggestion for a future release, maybe?
Andrew Nacin
wp at andrewnacin.com
Wed Jun 23 14:17:32 UTC 2010
On Wed, Jun 23, 2010 at 10:06 AM, Foolish Visions <shelly at foolishvisions.com
> wrote:
> Her issue was that her host had some server fixin' going on, and broke the
> connection to the database. It's intermittently connecting, so the site is
> doing this "Here's my pretty WP site!" to "OMG! I'm down in flames!" dance
> every few minutes. So she was wondering if there was a way to simply check
> if the connection was fine - if so, move on to WordPress, and if not,
> redirect to a "safety" folder in the site that would display some HTML (so
> the site wouldn't suffer from all kinds of headache-inducing activity).
>
> I suggested adding the following to her WordPress index.php file (the WP
> site is at the root), just after the call to require the wp-blog-header.php
> file:
>
> // grab the login info from the wp-config.php file and check connection
> $link = mysql_connect(DB_HOST, DB_USER, DB_PASSWORD);
> if (!$link) {
> // if no connection, redirect to HTML backup folder
> header('Location: http://www.whateversite.com/backup/);
> }
> mysql_close($link);
>
> Anyway, a couple of people chimed up and said it might be worth letting
> *you* all know about this to see if it was worthy of making it part of core
> someday. Or some kind of optional thing if people want to have it. I
> dunno.
You can create a file that resides at wp-content/db-error.php, and it will
be used in place of "Error establishing database connection". You can use it
to either display a nicer message, or to redirect elsewhere, etc.
Sounds like we've already acted on your feature request, then. :-)
More information about the wp-testers
mailing list