From 678ef2b1e1ac19d40781ab92e4baaff61359e2e2 Mon Sep 17 00:00:00 2001 From: Scott Taylor Date: Wed, 29 Jan 2014 05:28:12 +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. Built from https://develop.svn.wordpress.org/trunk@27056 git-svn-id: http://core.svn.wordpress.org/trunk@26929 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-includes/functions.php | 4 ++-- wp-includes/wp-db.php | 7 +++++++ 2 files changed, 9 insertions(+), 2 deletions(-) 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.