From 63e0d969b6f3347d25c8d5e416769ecb4f90ed3b Mon Sep 17 00:00:00 2001 From: Sergey Biryukov Date: Wed, 30 Sep 2020 12:07:13 +0000 Subject: [PATCH] Code Modernization: Return `false` from `wpdb::query()` if the query was filtered to an empty string using the `query` filter. This avoids a fatal error on PHP 8 caused by passing an empty string to `mysqli_query()`, and maintains the current behaviour. Follow-up to [48980], [48981]. See #50913, #50639. git-svn-id: https://develop.svn.wordpress.org/trunk@49072 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 ebcadb6ef0..80c117c1a0 100644 --- a/src/wp-includes/wp-db.php +++ b/src/wp-includes/wp-db.php @@ -1915,6 +1915,11 @@ class wpdb { */ $query = apply_filters( 'query', $query ); + if ( ! $query ) { + $this->insert_id = 0; + return false; + } + $this->flush(); // Log how the function was called.