WordPress.org

Make WordPress Core


Ignore:
Timestamp:
11/10/2014 05:39:50 AM (7 years ago)
Author:
pento
Message:

wpdb::flush() was not flushing results correctly when using mysqli.

This change also allows stored procedures or queries made with mysqli_multi_query() to be flushed.

Includes unit tests.

Fixes #28155.

Props soulseekah.

File:
1 edited

Legend:

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

    r30292 r30297  
    13231323        $this->last_error  = '';
    13241324
    1325         if ( is_resource( $this->result ) ) {
    1326             if ( $this->use_mysqli ) {
    1327                 mysqli_free_result( $this->result );
    1328             } else {
    1329                 mysql_free_result( $this->result );
    1330             }
     1325        if ( $this->use_mysqli && $this->result instanceof mysqli_result ) {
     1326            mysqli_free_result( $this->result );
     1327            $this->result = null;
     1328
     1329            // Clear out any results from a multi-query
     1330            while ( mysqli_more_results( $this->dbh ) ) {
     1331                mysqli_next_result( $this->dbh );
     1332            }
     1333        } else if ( is_resource( $this->result ) ) {
     1334            mysql_free_result( $this->result );
    13311335        }
    13321336    }
Note: See TracChangeset for help on using the changeset viewer.