From 62b57d889955647699cbd5f3dca2f0034e0749a0 Mon Sep 17 00:00:00 2001 From: Scott Taylor Date: Wed, 29 Jan 2014 05:27:24 +0000 Subject: [PATCH] In `wpdb::db_connect()`, allow the loading of a custom database error template - this is already allowed in `dead_db()`. In `dead_db()`, move the call to `wp_load_translations_early()` before the inclusion of the `db-error.php` file to allow translation in both locations before the template is loaded. Props sbruner, kovshenin. Fixes #25703. git-svn-id: https://develop.svn.wordpress.org/trunk@27056 602fd350-edb4-49c9-b593-d223f7449a82 --- src/wp-includes/functions.php | 4 ++-- src/wp-includes/wp-db.php | 7 +++++++ 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/src/wp-includes/functions.php b/src/wp-includes/functions.php index 9b0335b684..2d06fc32bb 100644 --- a/src/wp-includes/functions.php +++ b/src/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/src/wp-includes/wp-db.php b/src/wp-includes/wp-db.php index 9fcd4a7cab..35bb393c99 100644 --- a/src/wp-includes/wp-db.php +++ b/src/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.