Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Use wp_die() for WPDB bails. Send 500 response and no-cache headers s…

…o wp_die()s are not cached. props DD32. fixes #3471

git-svn-id: http://svn.automattic.com/wordpress/trunk@6110 1a063a9b-81f0-0310-95a4-ce76da25c4cd
  • Loading branch information...
commit b36471d4cf1429c92269443b4d2cbd4e9a547b0d 1 parent 9e61170
markjaquith authored
View
14 wp-includes/functions.php
@@ -1240,13 +1240,17 @@ function wp_die( $message, $title = '' ) {
else
$admin_dir = 'wp-admin/';
- if ( !did_action('admin_head') ) :
+ if ( !function_exists('did_action') || !did_action('admin_head') ) :
+ status_header(500);
+ nocache_headers();
header('Content-Type: text/html; charset=utf-8');
- if ( empty($title) )
- $title = __('WordPress › Error');
-
-
+ if ( empty($title) ){
+ if( function_exists('__') )
+ $title = __('WordPress › Error');
+ else
+ $title = 'WordPress › Error';
+ }
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
View
24 wp-includes/wp-db.php
@@ -401,29 +401,7 @@ function timer_stop() {
function bail($message) { // Just wraps errors in a nice header and footer
if ( !$this->show_errors )
return false;
-
- header('Content-Type: text/html; charset=utf-8');
-
- if (strpos($_SERVER['PHP_SELF'], 'wp-admin') !== false)
- $admin_dir = '';
- else
- $admin_dir = 'wp-admin/';
-
-?>
-<!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">
-<head>
- <title>WordPress &rsaquo; Error</title>
- <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
- <link rel="stylesheet" href="<?php echo $admin_dir; ?>install.css" type="text/css" />
-</head>
-<body>
- <h1 id="logo"><img alt="WordPress" src="<?php echo $admin_dir; ?>images/wordpress-logo.png" /></h1>
- <p><?php echo $message; ?></p>
-</body>
-</html>
-<?php
- die();
+ wp_die($message);
}
}
View
9 wp-settings.php
@@ -113,6 +113,10 @@ function timer_stop($display = 0, $precision = 3) { //if called like timer_stop(
if ( !defined('PLUGINDIR') )
define('PLUGINDIR', 'wp-content/plugins'); // no leading slash, no trailing slash
+
+require (ABSPATH . WPINC . '/compat.php');
+require (ABSPATH . WPINC . '/functions.php');
+
if ( file_exists(ABSPATH . 'wp-content/db.php') )
require_once (ABSPATH . 'wp-content/db.php');
else
@@ -122,7 +126,7 @@ function timer_stop($display = 0, $precision = 3) { //if called like timer_stop(
$wpdb->prefix = $table_prefix;
if ( preg_match('|[^a-z0-9_]|i', $wpdb->prefix) && !file_exists(ABSPATH . 'wp-content/db.php') )
- die("<strong>ERROR</strong>: <code>$table_prefix</code> in <code>wp-config.php</code> can only contain numbers, letters, and underscores.");
+ wp_die("<strong>ERROR</strong>: <code>$table_prefix</code> in <code>wp-config.php</code> can only contain numbers, letters, and underscores.");
// Table names
$wpdb->posts = $wpdb->prefix . 'posts';
@@ -151,9 +155,6 @@ function timer_stop($display = 0, $precision = 3) { //if called like timer_stop(
wp_cache_init();
-require (ABSPATH . WPINC . '/compat.php');
-require (ABSPATH . WPINC . '/functions.php');
-
require (ABSPATH . WPINC . '/classes.php');
require (ABSPATH . WPINC . '/plugin.php');
require (ABSPATH . WPINC . '/default-filters.php');
Please sign in to comment.
Something went wrong with that request. Please try again.