Make WordPress Core

Changeset 6443 for branches/2.3


Ignore:
Timestamp:
12/21/2007 01:31:31 AM (16 years ago)
Author:
ryan
Message:

Suppress display of DB error messages by default. Props filosofo. fixes #5473 for 2.3

Location:
branches/2.3/wp-includes
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • branches/2.3/wp-includes/functions.php

    r6232 r6443  
    199199        if ( false === $value ) {
    200200            if ( defined('WP_INSTALLING') )
    201                 $wpdb->hide_errors();
     201                $show = $wpdb->hide_errors();
    202202            $row = $wpdb->get_row("SELECT option_value FROM $wpdb->options WHERE option_name = '$setting' LIMIT 1");
    203203            if ( defined('WP_INSTALLING') )
    204                 $wpdb->show_errors();
     204                $wpdb->show_errors($show);
    205205
    206206            if( is_object( $row) ) { // Has to be get_row instead of get_var because of funkiness with 0, false, null values
     
    237237function get_alloptions() {
    238238    global $wpdb, $wp_queries;
    239     $wpdb->hide_errors();
     239    $show = $wpdb->hide_errors();
    240240    if ( !$options = $wpdb->get_results("SELECT option_name, option_value FROM $wpdb->options WHERE autoload = 'yes'") ) {
    241241        $options = $wpdb->get_results("SELECT option_name, option_value FROM $wpdb->options");
    242242    }
    243     $wpdb->show_errors();
     243    $wpdb->show_errors($show);
    244244
    245245    foreach ($options as $option) {
     
    264264
    265265    if ( !$alloptions ) {
    266         $wpdb->hide_errors();
     266        $show = $wpdb->hide_errors();
    267267        if ( !$alloptions_db = $wpdb->get_results("SELECT option_name, option_value FROM $wpdb->options WHERE autoload = 'yes'") )
    268268            $alloptions_db = $wpdb->get_results("SELECT option_name, option_value FROM $wpdb->options");
    269         $wpdb->show_errors();
     269        $wpdb->show_errors($show);
    270270        $alloptions = array();
    271271        foreach ( (array) $alloptions_db as $o )
     
    893893function is_blog_installed() {
    894894    global $wpdb;
    895     $wpdb->hide_errors();
     895    $show = $wpdb->hide_errors();
    896896    $installed = $wpdb->get_var("SELECT option_value FROM $wpdb->options WHERE option_name = 'siteurl'");
    897     $wpdb->show_errors();
     897    $wpdb->show_errors($show);
    898898
    899899    $install_status = !empty( $installed ) ? TRUE : FALSE;
  • branches/2.3/wp-includes/pluggable.php

    r6266 r6443  
    7373        return false;
    7474
    75     $wpdb->hide_errors();
     75    $show = $wpdb->hide_errors();
    7676    $metavalues = $wpdb->get_results("SELECT meta_key, meta_value FROM $wpdb->usermeta WHERE user_id = '$user_id'");
    77     $wpdb->show_errors();
     77    $wpdb->show_errors($show);
    7878
    7979    if ($metavalues) {
  • branches/2.3/wp-includes/wp-db.php

    r6110 r6443  
    1616class wpdb {
    1717
    18     var $show_errors = true;
     18    var $show_errors = false;
    1919    var $num_queries = 0;
    2020    var $last_query;
     
    150150        array ('query' => $this->last_query, 'error_str' => $str);
    151151
     152        $error_str = "WordPress database error $str for query $this->last_query";
     153        if ( $caller = $this->get_caller() )
     154            $error_str .= " made by $caller";
     155        error_log($error_str, 0);
     156
     157        // Is error output turned on or not..
     158        if ( !$this->show_errors )
     159            return false;
     160
    152161        $str = htmlspecialchars($str, ENT_QUOTES);
    153162        $query = htmlspecialchars($this->last_query, ENT_QUOTES);
    154         // Is error output turned on or not..
    155         if ( $this->show_errors ) {
    156             // If there is an error then take note of it
    157             print "<div id='error'>
    158             <p class='wpdberror'><strong>WordPress database error:</strong> [$str]<br />
    159             <code>$query</code></p>
    160             </div>";
    161         } else {
    162             return false;
    163         }
     163
     164        // If there is an error then take note of it
     165        print "<div id='error'>
     166        <p class='wpdberror'><strong>WordPress database error:</strong> [$str]<br />
     167        <code>$query</code></p>
     168        </div>";
    164169    }
    165170
     
    167172    //  Turn error handling on or off..
    168173
    169     function show_errors() {
    170         $this->show_errors = true;
     174    function show_errors( $show = true ) {
     175        $errors = $this->show_errors;
     176        $this->show_errors = $show;
     177        return $errors;
    171178    }
    172179
    173180    function hide_errors() {
     181        $show = $this->show_errors;
    174182        $this->show_errors = false;
     183        return $show;
    175184    }
    176185
Note: See TracChangeset for help on using the changeset viewer.