diff --git a/wp-includes/functions.php b/wp-includes/functions.php index 9b0335b684..2d06fc32bb 100644 --- a/wp-includes/functions.php +++ b/wp-includes/functions.php @@ -2793,6 +2793,8 @@ function wp_ob_end_flush_all() { function dead_db() { global $wpdb; + wp_load_translations_early(); + // Load custom DB error template, if present. if ( file_exists( WP_CONTENT_DIR . '/db-error.php' ) ) { require_once( WP_CONTENT_DIR . '/db-error.php' ); @@ -2807,8 +2809,6 @@ function dead_db() { status_header( 500 ); nocache_headers(); header( 'Content-Type: text/html; charset=utf-8' ); - - wp_load_translations_early(); ?> > diff --git a/wp-includes/wp-db.php b/wp-includes/wp-db.php index 9fcd4a7cab..35bb393c99 100644 --- a/wp-includes/wp-db.php +++ b/wp-includes/wp-db.php @@ -1154,6 +1154,13 @@ class wpdb { if ( !$this->dbh ) { wp_load_translations_early(); + + // 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(); + } + $this->bail( sprintf( __( "

Error establishing a database connection

This either means that the username and password information in your wp-config.php file is incorrect or we can't contact the database server at %s. This could mean your host's database server is down.