dead_db

The timeline below displays how wordpress function dead_db has changed across different WordPress versions. If a version is not listed, refer to the next available version below.

WordPress Version: 6.1

/**
 * Loads custom DB error or display WordPress DB error.
 *
 * If a file exists in the wp-content directory named db-error.php, then it will
 * be loaded instead of displaying the WordPress DB error. If it is not found,
 * then the WordPress DB error will be displayed instead.
 *
 * The WordPress DB error sets the HTTP status header to 500 to try to prevent
 * search engines from caching the message. Custom DB messages should do the
 * same.
 *
 * This function was backported to WordPress 2.3.2, but originally was added
 * in WordPress 2.5.0.
 *
 * @since 2.3.2
 *
 * @global wpdb $wpdb WordPress database abstraction object.
 */
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';
        die;
    }
    // If installing or in the admin, provide the verbose message.
    if (wp_installing() || defined('WP_ADMIN')) {
        wp_die($wpdb->error);
    }
    // Otherwise, be terse.
    wp_die('<h1>' . __('Error establishing a database connection') . '</h1>', __('Database Error'));
}

WordPress Version: 5.2

/**
 * Load custom DB error or display WordPress DB error.
 *
 * If a file exists in the wp-content directory named db-error.php, then it will
 * be loaded instead of displaying the WordPress DB error. If it is not found,
 * then the WordPress DB error will be displayed instead.
 *
 * The WordPress DB error sets the HTTP status header to 500 to try to prevent
 * search engines from caching the message. Custom DB messages should do the
 * same.
 *
 * This function was backported to WordPress 2.3.2, but originally was added
 * in WordPress 2.5.0.
 *
 * @since 2.3.2
 *
 * @global wpdb $wpdb WordPress database abstraction object.
 */
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';
        die;
    }
    // If installing or in the admin, provide the verbose message.
    if (wp_installing() || defined('WP_ADMIN')) {
        wp_die($wpdb->error);
    }
    // Otherwise, be terse.
    wp_die('<h1>' . __('Error establishing a database connection') . '</h1>', __('Database Error'));
}

WordPress Version: 5.1

/**
 * Load custom DB error or display WordPress DB error.
 *
 * If a file exists in the wp-content directory named db-error.php, then it will
 * be loaded instead of displaying the WordPress DB error. If it is not found,
 * then the WordPress DB error will be displayed instead.
 *
 * The WordPress DB error sets the HTTP status header to 500 to try to prevent
 * search engines from caching the message. Custom DB messages should do the
 * same.
 *
 * This function was backported to WordPress 2.3.2, but originally was added
 * in WordPress 2.5.0.
 *
 * @since 2.3.2
 *
 * @global wpdb $wpdb WordPress database abstraction object.
 */
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';
        die;
    }
    // If installing or in the admin, provide the verbose message.
    if (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');
    $dir_attr = '';
    if (is_rtl()) {
        $dir_attr = ' dir="rtl"';
    }
    ?>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml"<?php 
    echo $dir_attr;
    ?>>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
	<title><?php 
    _e('Database Error');
    ?></title>

</head>
<body>
	<h1><?php 
    _e('Error establishing a database connection');
    ?></h1>
</body>
</html>
	<?php 
    die;
}

WordPress Version: 4.4

/**
 * Load custom DB error or display WordPress DB error.
 *
 * If a file exists in the wp-content directory named db-error.php, then it will
 * be loaded instead of displaying the WordPress DB error. If it is not found,
 * then the WordPress DB error will be displayed instead.
 *
 * The WordPress DB error sets the HTTP status header to 500 to try to prevent
 * search engines from caching the message. Custom DB messages should do the
 * same.
 *
 * This function was backported to WordPress 2.3.2, but originally was added
 * in WordPress 2.5.0.
 *
 * @since 2.3.2
 *
 * @global wpdb $wpdb WordPress database abstraction object.
 */
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';
        die;
    }
    // If installing or in the admin, provide the verbose message.
    if (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>
<html xmlns="http://www.w3.org/1999/xhtml"<?php 
    if (is_rtl()) {
        echo ' dir="rtl"';
    }
    ?>>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
	<title><?php 
    _e('Database Error');
    ?></title>

</head>
<body>
	<h1><?php 
    _e('Error establishing a database connection');
    ?></h1>
</body>
</html>
<?php 
    die;
}

WordPress Version: 4.1

/**
 * Load custom DB error or display WordPress DB error.
 *
 * If a file exists in the wp-content directory named db-error.php, then it will
 * be loaded instead of displaying the WordPress DB error. If it is not found,
 * then the WordPress DB error will be displayed instead.
 *
 * The WordPress DB error sets the HTTP status header to 500 to try to prevent
 * search engines from caching the message. Custom DB messages should do the
 * same.
 *
 * This function was backported to WordPress 2.3.2, but originally was added
 * in WordPress 2.5.0.
 *
 * @since 2.3.2
 *
 * @global wpdb $wpdb WordPress database abstraction object.
 */
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';
        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>
<html xmlns="http://www.w3.org/1999/xhtml"<?php 
    if (is_rtl()) {
        echo ' dir="rtl"';
    }
    ?>>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
	<title><?php 
    _e('Database Error');
    ?></title>

</head>
<body>
	<h1><?php 
    _e('Error establishing a database connection');
    ?></h1>
</body>
</html>
<?php 
    die;
}

WordPress Version: 4.0

/**
 * Load custom DB error or display WordPress DB error.
 *
 * If a file exists in the wp-content directory named db-error.php, then it will
 * be loaded instead of displaying the WordPress DB error. If it is not found,
 * then the WordPress DB error will be displayed instead.
 *
 * The WordPress DB error sets the HTTP status header to 500 to try to prevent
 * search engines from caching the message. Custom DB messages should do the
 * same.
 *
 * This function was backported to WordPress 2.3.2, but originally was added
 * in WordPress 2.5.0.
 *
 * @since 2.3.2
 *
 * @global wpdb $wpdb WordPress database access abstraction object.
 */
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';
        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>
<html xmlns="http://www.w3.org/1999/xhtml"<?php 
    if (is_rtl()) {
        echo ' dir="rtl"';
    }
    ?>>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
	<title><?php 
    _e('Database Error');
    ?></title>

</head>
<body>
	<h1><?php 
    _e('Error establishing a database connection');
    ?></h1>
</body>
</html>
<?php 
    die;
}

WordPress Version: 3.9

/**
 * Load custom DB error or display WordPress DB error.
 *
 * If a file exists in the wp-content directory named db-error.php, then it will
 * be loaded instead of displaying the WordPress DB error. If it is not found,
 * then the WordPress DB error will be displayed instead.
 *
 * The WordPress DB error sets the HTTP status header to 500 to try to prevent
 * search engines from caching the message. Custom DB messages should do the
 * same.
 *
 * This function was backported to WordPress 2.3.2, but originally was added
 * in WordPress 2.5.0.
 *
 * @since 2.3.2
 * @uses $wpdb
 */
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';
        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>
<html xmlns="http://www.w3.org/1999/xhtml"<?php 
    if (is_rtl()) {
        echo ' dir="rtl"';
    }
    ?>>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
	<title><?php 
    _e('Database Error');
    ?></title>

</head>
<body>
	<h1><?php 
    _e('Error establishing a database connection');
    ?></h1>
</body>
</html>
<?php 
    die;
}

WordPress Version: 3.7

/**
 * Load custom DB error or display WordPress DB error.
 *
 * If a file exists in the wp-content directory named db-error.php, then it will
 * be loaded instead of displaying the WordPress DB error. If it is not found,
 * then the WordPress DB error will be displayed instead.
 *
 * The WordPress DB error sets the HTTP status header to 500 to try to prevent
 * search engines from caching the message. Custom DB messages should do the
 * same.
 *
 * This function was backported to WordPress 2.3.2, but originally was added
 * in WordPress 2.5.0.
 *
 * @since 2.3.2
 * @uses $wpdb
 */
function dead_db()
{
    global $wpdb;
    // 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;
    }
    // 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');
    wp_load_translations_early();
    ?>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml"<?php 
    if (is_rtl()) {
        echo ' dir="rtl"';
    }
    ?>>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
	<title><?php 
    _e('Database Error');
    ?></title>

</head>
<body>
	<h1><?php 
    _e('Error establishing a database connection');
    ?></h1>
</body>
</html>
<?php 
    die;
}