From 0013150649c7a7e41879508c83dc9951fb2816d2 Mon Sep 17 00:00:00 2001 From: Gary Pendergast Date: Mon, 10 Nov 2014 05:40:23 +0000 Subject: [PATCH] `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. Built from https://develop.svn.wordpress.org/trunk@30297 git-svn-id: http://core.svn.wordpress.org/trunk@30296 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-includes/version.php | 2 +- wp-includes/wp-db.php | 14 +++++++++----- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/wp-includes/version.php b/wp-includes/version.php index fc30f64eb6..505a106eec 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -4,7 +4,7 @@ * * @global string $wp_version */ -$wp_version = '4.1-alpha-30296'; +$wp_version = '4.1-alpha-30297'; /** * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema. diff --git a/wp-includes/wp-db.php b/wp-includes/wp-db.php index 2e8b4079fe..f01ba97a8c 100644 --- a/wp-includes/wp-db.php +++ b/wp-includes/wp-db.php @@ -1322,12 +1322,16 @@ class wpdb { $this->rows_affected = $this->num_rows = 0; $this->last_error = ''; - if ( is_resource( $this->result ) ) { - if ( $this->use_mysqli ) { - mysqli_free_result( $this->result ); - } else { - mysql_free_result( $this->result ); + if ( $this->use_mysqli && $this->result instanceof mysqli_result ) { + mysqli_free_result( $this->result ); + $this->result = null; + + // Clear out any results from a multi-query + while ( mysqli_more_results( $this->dbh ) ) { + mysqli_next_result( $this->dbh ); } + } else if ( is_resource( $this->result ) ) { + mysql_free_result( $this->result ); } }