From e8dc86950e89312fdfd358653c26d0bd3c236377 Mon Sep 17 00:00:00 2001 From: ryan Date: Fri, 21 Dec 2007 02:53:57 +0000 Subject: [PATCH] Custom DB error page. fixes #5500 for 2.4 git-svn-id: http://svn.automattic.com/wordpress/trunk@6447 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-includes/functions.php | 32 ++++++++++++++++++++++++++++++++ wp-settings.php | 4 ++++ 2 files changed, 36 insertions(+) diff --git a/wp-includes/functions.php b/wp-includes/functions.php index dca06c3610..a2a5fb4f85 100644 --- a/wp-includes/functions.php +++ b/wp-includes/functions.php @@ -1529,6 +1529,37 @@ function require_wp_db() { require_once( ABSPATH . WPINC . '/wp-db.php' ); } +function dead_db() { + global $wpdb; + + // Load custom DB error template, if present. + if ( file_exists( ABSPATH . 'wp-content/db-error.php' ) ) { + require_once( ABSPATH . 'wp-content/db-error.php' ); + die(); + } + + // If installing or in the admin, provide the verbose message. + if ( defined('WP_INSTALLING') || defined('WP_ADMIN') ) + wp_die($wpdb->error); + + // Otherwise, be terse. + status_header( 500 ); + nocache_headers(); + header( 'Content-Type: text/html; charset=utf-8' ); +?> + +> + + Database Error + + + +

Error establishing a database connection

+ + + diff --git a/wp-settings.php b/wp-settings.php index 96131f2243..2d40b4a935 100644 --- a/wp-settings.php +++ b/wp-settings.php @@ -196,6 +196,10 @@ require (ABSPATH . WPINC . '/functions.php'); require (ABSPATH . WPINC . '/classes.php'); require_wp_db(); + +if ( !empty($wpdb->error) ) + dead_db(); + $prefix = $wpdb->set_prefix($table_prefix); if ( is_wp_error($prefix) )