[wp-hackers] Change "Error Establishing a Database Connection" error message

Nicholas Ciske nl at thoughtrefinery.com
Tue Apr 15 17:39:00 UTC 2014


No filter, but the template can be overridden... and that could send an email.

// Load custom DB error template, if present.
if ( file_exists( WP_CONTENT_DIR . '/db-error.php' ) ) {
	require_once( WP_CONTENT_DIR . '/db-error.php' );
	die();
}

See line ~1388 here:
https://github.com/WordPress/WordPress/blob/1860b6a007c568b50344d113fe6490713479ad6a/wp-includes/wp-db.php

And dead_db() on line ~1955 here:
https://github.com/WordPress/WordPress/blob/ca7ef18e55481de51dad2f9f234ffa8461f3a209/wp-includes/functions.php#L2987

On multisite you can filter wp_die() to check for that message and alter it/send an email.

See line ~401 here:
https://github.com/WordPress/WordPress/blob/827b92a9bd8a84c0ce73b55079675e9a2b0a14e7/wp-includes/ms-load.php

wp_die
https://codex.wordpress.org/Function_Reference/wp_die

_________________________
Nick Ciske
http://thoughtrefinery.com/
@nciske	

On Apr 15, 2014, at 12:27 PM, Ryan B <cloudpresshosting at gmail.com> wrote:

> I am wanting to change this error message to something a little more useful
> to an end user, and also have it trigger an email alert to me if this error
> occurs. Is there a hook or filter I could use to change the output given to
> the user when a database connection error occurs?



More information about the wp-hackers mailing list