Custom DB error page. fixes #5500 for 2.4

git-svn-id: http://svn.automattic.com/wordpress/trunk@6447 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
ryan 2007-12-21 02:53:57 +00:00
parent e6080b4926
commit e8dc86950e
2 changed files with 36 additions and 0 deletions

View File

@ -1529,6 +1529,37 @@ function require_wp_db() {
require_once( ABSPATH . WPINC . '/wp-db.php' ); 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' );
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" <?php if ( function_exists( 'language_attributes' ) ) language_attributes(); ?>>
<head>
<title>Database Error</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
</head>
<body>
<h1>Error establishing a database connection</h1>
</body>
</html>
<?php
die();
}
/** /**
* Converts input to an absolute integer * Converts input to an absolute integer
@ -1573,4 +1604,5 @@ function atom_service_url_filter($url)
else else
return $url; return $url;
} }
?> ?>

View File

@ -196,6 +196,10 @@ require (ABSPATH . WPINC . '/functions.php');
require (ABSPATH . WPINC . '/classes.php'); require (ABSPATH . WPINC . '/classes.php');
require_wp_db(); require_wp_db();
if ( !empty($wpdb->error) )
dead_db();
$prefix = $wpdb->set_prefix($table_prefix); $prefix = $wpdb->set_prefix($table_prefix);
if ( is_wp_error($prefix) ) if ( is_wp_error($prefix) )