WordPress.org

Make WordPress Core

Changeset 35860


Ignore:
Timestamp:
12/11/2015 03:39:52 AM (4 years ago)
Author:
ericlewis
Message:

Don't suppress error messages in database function calls.

Fixes #21870.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/wp-db.php

    r35787 r35860  
    10451045
    10461046        if ( $this->use_mysqli ) {
    1047             $success = @mysqli_select_db( $dbh, $db );
     1047            $success = mysqli_select_db( $dbh, $db );
    10481048        } else {
    1049             $success = @mysql_select_db( $db, $dbh );
     1049            $success = mysql_select_db( $db, $dbh );
    10501050        }
    10511051        if ( ! $success ) {
     
    14851485            }
    14861486
    1487             if ( WP_DEBUG ) {
    1488                 mysqli_real_connect( $this->dbh, $host, $this->dbuser, $this->dbpassword, null, $port, $socket, $client_flags );
    1489             } else {
    1490                 @mysqli_real_connect( $this->dbh, $host, $this->dbuser, $this->dbpassword, null, $port, $socket, $client_flags );
    1491             }
     1487            mysqli_real_connect( $this->dbh, $host, $this->dbuser, $this->dbpassword, null, $port, $socket, $client_flags );
    14921488
    14931489            if ( $this->dbh->connect_errno ) {
     
    15151511            }
    15161512        } else {
    1517             if ( WP_DEBUG ) {
    1518                 $this->dbh = mysql_connect( $this->dbhost, $this->dbuser, $this->dbpassword, $new_link, $client_flags );
    1519             } else {
    1520                 $this->dbh = @mysql_connect( $this->dbhost, $this->dbuser, $this->dbpassword, $new_link, $client_flags );
    1521             }
     1513            $this->dbh = mysql_connect( $this->dbhost, $this->dbuser, $this->dbpassword, $new_link, $client_flags );
    15221514        }
    15231515
     
    15901582    public function check_connection( $allow_bail = true ) {
    15911583        if ( $this->use_mysqli ) {
    1592             if ( @mysqli_ping( $this->dbh ) ) {
     1584            if ( ! empty( $this->dbh ) && mysqli_ping( $this->dbh ) ) {
    15931585                return true;
    15941586            }
    15951587        } else {
    1596             if ( @mysql_ping( $this->dbh ) ) {
     1588            if ( ! empty( $this->dbh ) && mysql_ping( $this->dbh ) ) {
    15971589                return true;
    15981590            }
     
    17711763            $num_rows = 0;
    17721764            if ( $this->use_mysqli && $this->result instanceof mysqli_result ) {
    1773                 while ( $row = @mysqli_fetch_object( $this->result ) ) {
     1765                while ( $row = mysqli_fetch_object( $this->result ) ) {
    17741766                    $this->last_result[$num_rows] = $row;
    17751767                    $num_rows++;
    17761768                }
    17771769            } elseif ( is_resource( $this->result ) ) {
    1778                 while ( $row = @mysql_fetch_object( $this->result ) ) {
     1770                while ( $row = mysql_fetch_object( $this->result ) ) {
    17791771                    $this->last_result[$num_rows] = $row;
    17801772                    $num_rows++;
     
    18061798        }
    18071799
    1808         if ( $this->use_mysqli ) {
    1809             $this->result = @mysqli_query( $this->dbh, $query );
    1810         } else {
    1811             $this->result = @mysql_query( $query, $this->dbh );
     1800        if ( ! empty( $this->dbh ) && $this->use_mysqli ) {
     1801            $this->result = mysqli_query( $this->dbh, $query );
     1802        } elseif ( ! empty( $this->dbh ) ) {
     1803            $this->result = mysql_query( $query, $this->dbh );
    18121804        }
    18131805        $this->num_queries++;
     
    30173009
    30183010        if ( $this->use_mysqli ) {
    3019             $num_fields = @mysqli_num_fields( $this->result );
     3011            $num_fields = mysqli_num_fields( $this->result );
    30203012            for ( $i = 0; $i < $num_fields; $i++ ) {
    3021                 $this->col_info[ $i ] = @mysqli_fetch_field( $this->result );
     3013                $this->col_info[ $i ] = mysqli_fetch_field( $this->result );
    30223014            }
    30233015        } else {
    3024             $num_fields = @mysql_num_fields( $this->result );
     3016            $num_fields = mysql_num_fields( $this->result );
    30253017            for ( $i = 0; $i < $num_fields; $i++ ) {
    3026                 $this->col_info[ $i ] = @mysql_fetch_field( $this->result, $i );
     3018                $this->col_info[ $i ] = mysql_fetch_field( $this->result, $i );
    30273019            }
    30283020        }
Note: See TracChangeset for help on using the changeset viewer.