From 5d12c48818340cbdb58cb771eb02ab26e6fa715d Mon Sep 17 00:00:00 2001 From: Mark Jaquith Date: Thu, 13 Sep 2007 06:23:23 +0000 Subject: [PATCH] Use wp_die() for WPDB bails. Send 500 response and no-cache headers so wp_die()s are not cached. props DD32. fixes #3471 git-svn-id: https://develop.svn.wordpress.org/trunk@6110 602fd350-edb4-49c9-b593-d223f7449a82 --- wp-includes/functions.php | 14 +++++++++----- wp-includes/wp-db.php | 24 +----------------------- wp-settings.php | 9 +++++---- 3 files changed, 15 insertions(+), 32 deletions(-) diff --git a/wp-includes/functions.php b/wp-includes/functions.php index abc71c377a..4a1d74edf0 100644 --- a/wp-includes/functions.php +++ b/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'; + } ?> diff --git a/wp-includes/wp-db.php b/wp-includes/wp-db.php index 60171cc143..a2b98c7c66 100644 --- a/wp-includes/wp-db.php +++ b/wp-includes/wp-db.php @@ -401,29 +401,7 @@ class wpdb { 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/'; - -?> - - - - WordPress › Error - - - - -

WordPress

-

- - -prefix = $table_prefix; if ( preg_match('|[^a-z0-9_]|i', $wpdb->prefix) && !file_exists(ABSPATH . 'wp-content/db.php') ) - die("ERROR: $table_prefix in wp-config.php can only contain numbers, letters, and underscores."); + wp_die("ERROR: $table_prefix in wp-config.php can only contain numbers, letters, and underscores."); // Table names $wpdb->posts = $wpdb->prefix . 'posts'; @@ -151,9 +155,6 @@ else 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');