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 );