diff --git a/src/wp-includes/wp-db.php b/src/wp-includes/wp-db.php index 421db3671d..95b9212904 100644 --- a/src/wp-includes/wp-db.php +++ b/src/wp-includes/wp-db.php @@ -969,8 +969,9 @@ class wpdb { } if ( ! $success ) { $this->ready = false; - wp_load_translations_early(); - $this->bail( sprintf( __( '
We were able to connect to the database server (which means your username and password is okay) but not able to select the %1$s database.
username_%1$s. Could that be the problem?If you don\'t know how to set up a database you should contact your host. If all else fails you may find help at the WordPress Support Forums.
' ), htmlspecialchars( $db, ENT_QUOTES ), htmlspecialchars( $this->dbuser, ENT_QUOTES ) ), 'db_select_fail' ); + } return; } } @@ -1378,7 +1380,8 @@ class wpdb { /** * Check that the connection to the database is still up. If not, try to reconnect. * - * If this function is unable to reconnect, it will forcibly die. + * If this function is unable to reconnect, it will forcibly die, or if after the + * the template_redirect hook has been fired, return false instead. * * @since 3.9.0 * @@ -1421,6 +1424,12 @@ class wpdb { sleep( 1 ); } + // If template_redirect has already happened, it's too late for wp_die()/dead_db(). + // Let's just return and hope for the best. + if ( did_action( 'template_redirect' ) ) { + return false; + } + // We weren't able to reconnect, so we better bail. $this->bail( sprintf( ( "