WordPress.org

Make WordPress Core

Ticket #37508: 37508.patch

File 37508.patch, 749 bytes (added by procodewp, 4 years ago)

Checks that this->result is valid before calling mysqli_num_fields() and mysql_num_fields()

  • wp-includes/wp-db.php

     
    30803080                if ( $this->col_info )
    30813081                        return;
    30823082
    3083                 if ( $this->use_mysqli ) {
     3083                if ( $this->use_mysqli && $this->result instanceof mysqli_result ) {
    30843084                        $num_fields = mysqli_num_fields( $this->result );
    30853085                        for ( $i = 0; $i < $num_fields; $i++ ) {
    30863086                                $this->col_info[ $i ] = mysqli_fetch_field( $this->result );
    30873087                        }
    3088                 } else {
     3088                } elseif ( is_resource( $this->result ) ) {
    30893089                        $num_fields = mysql_num_fields( $this->result );
    30903090                        for ( $i = 0; $i < $num_fields; $i++ ) {
    30913091                                $this->col_info[ $i ] = mysql_fetch_field( $this->result, $i );