From c2fb136b4784c8162619b6c73d2ebf9607f95d5b Mon Sep 17 00:00:00 2001 From: Gary Pendergast Date: Tue, 11 Nov 2014 02:16:19 +0000 Subject: [PATCH] wpdb: When flushing results on a mysqli connection, make sure that `wpdb::$dbh` is a valid mysqli connection handle. Fixes a unit test failure introduced in [30297]. Fixes #28155. Props soulseekah. git-svn-id: https://develop.svn.wordpress.org/trunk@30299 602fd350-edb4-49c9-b593-d223f7449a82 --- src/wp-includes/wp-db.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/wp-includes/wp-db.php b/src/wp-includes/wp-db.php index f01ba97a8c..8e4d2a42e5 100644 --- a/src/wp-includes/wp-db.php +++ b/src/wp-includes/wp-db.php @@ -1326,6 +1326,11 @@ class wpdb { mysqli_free_result( $this->result ); $this->result = null; + // Sanity check before using the handle + if ( empty( $this->dbh ) || !( $this->dbh instanceof mysqli ) ) { + return; + } + // Clear out any results from a multi-query while ( mysqli_more_results( $this->dbh ) ) { mysqli_next_result( $this->dbh );