From 9734ed5673f6e7b3d8146c6bc7a0e8b82abe5d4a Mon Sep 17 00:00:00 2001 From: Sergey Biryukov Date: Wed, 16 Sep 2020 01:48:10 +0000 Subject: [PATCH] Code Modernization: Return an empty string from `wpdb::_real_escape()` if a non-scalar value is passed. This avoids a fatal error on PHP 8 caused by passing a non-string value to ` mysqli_real_escape_string()`, and maintains the current behaviour. See #50913, #50639. Built from https://develop.svn.wordpress.org/trunk@48980 git-svn-id: http://core.svn.wordpress.org/trunk@48742 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-includes/version.php | 2 +- wp-includes/wp-db.php | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/wp-includes/version.php b/wp-includes/version.php index 9ee377202b..7289f20059 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -13,7 +13,7 @@ * * @global string $wp_version */ -$wp_version = '5.6-alpha-48979'; +$wp_version = '5.6-alpha-48980'; /** * 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 2e392d0954..9761de99a8 100644 --- a/wp-includes/wp-db.php +++ b/wp-includes/wp-db.php @@ -1159,6 +1159,10 @@ class wpdb { * @return string Escaped string. */ function _real_escape( $string ) { + if ( ! is_scalar( $string ) && ! is_null( $string ) ) { + return ''; + } + if ( $this->dbh ) { if ( $this->use_mysqli ) { $escaped = mysqli_real_escape_string( $this->dbh, $string );