Suppress display of DB error messages by default. Props filosofo. see #5473
git-svn-id: http://svn.automattic.com/wordpress/trunk@6391 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
e9c9b1fbf2
commit
0cbe2f0d84
|
@ -206,11 +206,11 @@ function get_option( $setting ) {
|
||||||
|
|
||||||
if ( false === $value ) {
|
if ( false === $value ) {
|
||||||
if ( defined( 'WP_INSTALLING' ) )
|
if ( defined( 'WP_INSTALLING' ) )
|
||||||
$wpdb->hide_errors();
|
$show = $wpdb->hide_errors();
|
||||||
// expected_slashed ($setting)
|
// expected_slashed ($setting)
|
||||||
$row = $wpdb->get_row( "SELECT option_value FROM $wpdb->options WHERE option_name = '$setting' LIMIT 1" );
|
$row = $wpdb->get_row( "SELECT option_value FROM $wpdb->options WHERE option_name = '$setting' LIMIT 1" );
|
||||||
if ( defined( 'WP_INSTALLING' ) )
|
if ( defined( 'WP_INSTALLING' ) )
|
||||||
$wpdb->show_errors();
|
$wpdb->show_errors($show);
|
||||||
|
|
||||||
if ( is_object( $row) ) { // Has to be get_row instead of get_var because of funkiness with 0, false, null values
|
if ( is_object( $row) ) { // Has to be get_row instead of get_var because of funkiness with 0, false, null values
|
||||||
$value = $row->option_value;
|
$value = $row->option_value;
|
||||||
|
@ -246,10 +246,10 @@ function form_option( $option ) {
|
||||||
|
|
||||||
function get_alloptions() {
|
function get_alloptions() {
|
||||||
global $wpdb, $wp_queries;
|
global $wpdb, $wp_queries;
|
||||||
$wpdb->hide_errors();
|
$show = $wpdb->hide_errors();
|
||||||
if ( !$options = $wpdb->get_results( "SELECT option_name, option_value FROM $wpdb->options WHERE autoload = 'yes'" ) )
|
if ( !$options = $wpdb->get_results( "SELECT option_name, option_value FROM $wpdb->options WHERE autoload = 'yes'" ) )
|
||||||
$options = $wpdb->get_results( "SELECT option_name, option_value FROM $wpdb->options" );
|
$options = $wpdb->get_results( "SELECT option_name, option_value FROM $wpdb->options" );
|
||||||
$wpdb->show_errors();
|
$wpdb->show_errors($show);
|
||||||
|
|
||||||
foreach ( $options as $option ) {
|
foreach ( $options as $option ) {
|
||||||
// "When trying to design a foolproof system,
|
// "When trying to design a foolproof system,
|
||||||
|
@ -269,10 +269,10 @@ function wp_load_alloptions() {
|
||||||
$alloptions = wp_cache_get( 'alloptions', 'options' );
|
$alloptions = wp_cache_get( 'alloptions', 'options' );
|
||||||
|
|
||||||
if ( !$alloptions ) {
|
if ( !$alloptions ) {
|
||||||
$wpdb->hide_errors();
|
$show = $wpdb->hide_errors();
|
||||||
if ( !$alloptions_db = $wpdb->get_results( "SELECT option_name, option_value FROM $wpdb->options WHERE autoload = 'yes'" ) )
|
if ( !$alloptions_db = $wpdb->get_results( "SELECT option_name, option_value FROM $wpdb->options WHERE autoload = 'yes'" ) )
|
||||||
$alloptions_db = $wpdb->get_results( "SELECT option_name, option_value FROM $wpdb->options" );
|
$alloptions_db = $wpdb->get_results( "SELECT option_name, option_value FROM $wpdb->options" );
|
||||||
$wpdb->show_errors();
|
$wpdb->show_errors($show);
|
||||||
$alloptions = array();
|
$alloptions = array();
|
||||||
foreach ( (array) $alloptions_db as $o )
|
foreach ( (array) $alloptions_db as $o )
|
||||||
$alloptions[$o->option_name] = $o->option_value;
|
$alloptions[$o->option_name] = $o->option_value;
|
||||||
|
@ -949,9 +949,9 @@ function is_blog_installed() {
|
||||||
if ( wp_cache_get('is_blog_installed') )
|
if ( wp_cache_get('is_blog_installed') )
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
$wpdb->hide_errors();
|
$show = $wpdb->hide_errors();
|
||||||
$installed = $wpdb->get_var( "SELECT option_value FROM $wpdb->options WHERE option_name = 'siteurl'" );
|
$installed = $wpdb->get_var( "SELECT option_value FROM $wpdb->options WHERE option_name = 'siteurl'" );
|
||||||
$wpdb->show_errors();
|
$wpdb->show_errors($show);
|
||||||
|
|
||||||
$installed = !empty( $installed ) ? true : false;
|
$installed = !empty( $installed ) ? true : false;
|
||||||
wp_cache_set('is_blog_installed', $installed);
|
wp_cache_set('is_blog_installed', $installed);
|
||||||
|
|
|
@ -236,9 +236,9 @@ function wp_dropdown_users( $args = '' ) {
|
||||||
function _fill_user( &$user ) {
|
function _fill_user( &$user ) {
|
||||||
global $wpdb;
|
global $wpdb;
|
||||||
|
|
||||||
$wpdb->hide_errors();
|
$show = $wpdb->hide_errors();
|
||||||
$metavalues = $wpdb->get_results($wpdb->prepare("SELECT meta_key, meta_value FROM $wpdb->usermeta WHERE user_id = %d", $user->ID));
|
$metavalues = $wpdb->get_results($wpdb->prepare("SELECT meta_key, meta_value FROM $wpdb->usermeta WHERE user_id = %d", $user->ID));
|
||||||
$wpdb->show_errors();
|
$wpdb->show_errors($show);
|
||||||
|
|
||||||
if ( $metavalues ) {
|
if ( $metavalues ) {
|
||||||
foreach ( $metavalues as $meta ) {
|
foreach ( $metavalues as $meta ) {
|
||||||
|
|
|
@ -15,7 +15,7 @@ if (!defined('SAVEQUERIES'))
|
||||||
|
|
||||||
class wpdb {
|
class wpdb {
|
||||||
|
|
||||||
var $show_errors = true;
|
var $show_errors = false;
|
||||||
var $num_queries = 0;
|
var $num_queries = 0;
|
||||||
var $last_query;
|
var $last_query;
|
||||||
var $col_info;
|
var $col_info;
|
||||||
|
@ -170,29 +170,38 @@ class wpdb {
|
||||||
$EZSQL_ERROR[] =
|
$EZSQL_ERROR[] =
|
||||||
array ('query' => $this->last_query, 'error_str' => $str);
|
array ('query' => $this->last_query, 'error_str' => $str);
|
||||||
|
|
||||||
|
$error_str = "WordPress database error $str for query $this->last_query";
|
||||||
|
if ( $caller = $this->get_caller() )
|
||||||
|
$error_str .= " made by $caller";
|
||||||
|
error_log($error_str, 0);
|
||||||
|
|
||||||
|
// Is error output turned on or not..
|
||||||
|
if ( !$this->show_errors )
|
||||||
|
return false;
|
||||||
|
|
||||||
$str = htmlspecialchars($str, ENT_QUOTES);
|
$str = htmlspecialchars($str, ENT_QUOTES);
|
||||||
$query = htmlspecialchars($this->last_query, ENT_QUOTES);
|
$query = htmlspecialchars($this->last_query, ENT_QUOTES);
|
||||||
// Is error output turned on or not..
|
|
||||||
if ( $this->show_errors ) {
|
// If there is an error then take note of it
|
||||||
// If there is an error then take note of it
|
print "<div id='error'>
|
||||||
print "<div id='error'>
|
<p class='wpdberror'><strong>WordPress database error:</strong> [$str]<br />
|
||||||
<p class='wpdberror'><strong>WordPress database error:</strong> [$str]<br />
|
<code>$query</code></p>
|
||||||
<code>$query</code></p>
|
</div>";
|
||||||
</div>";
|
|
||||||
} else {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// ==================================================================
|
// ==================================================================
|
||||||
// Turn error handling on or off..
|
// Turn error handling on or off..
|
||||||
|
|
||||||
function show_errors() {
|
function show_errors( $show = true ) {
|
||||||
$this->show_errors = true;
|
$errors = $this->show_errors;
|
||||||
|
$this->show_errors = $show;
|
||||||
|
return $errors;
|
||||||
}
|
}
|
||||||
|
|
||||||
function hide_errors() {
|
function hide_errors() {
|
||||||
|
$show = $this->show_errors;
|
||||||
$this->show_errors = false;
|
$this->show_errors = false;
|
||||||
|
return $show;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ==================================================================
|
// ==================================================================
|
||||||
|
|
Loading…
Reference in New Issue