From c588aebc84ef753663ff40b4db65f3b4d429bbc0 Mon Sep 17 00:00:00 2001 From: Sergey Biryukov Date: Sat, 28 Jan 2023 20:58:12 +0000 Subject: [PATCH] Database: Replace `substr_compare()` usage with `substr()` in `wpdb::prepare()`. This amends the previous commit to avoid a warning on PHP < 7.2.18 if haystack is an empty string: {{{ Warning: substr_compare(): The start position cannot exceed initial string length }}} Follow-up to [55151], [55157]. See #52506. Built from https://develop.svn.wordpress.org/trunk@55158 git-svn-id: http://core.svn.wordpress.org/trunk@54691 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-includes/class-wpdb.php | 4 ++-- wp-includes/version.php | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/wp-includes/class-wpdb.php b/wp-includes/class-wpdb.php index 22c54e75ee..1c7899a9ad 100644 --- a/wp-includes/class-wpdb.php +++ b/wp-includes/class-wpdb.php @@ -1562,7 +1562,7 @@ class wpdb { $type = substr( $placeholder, -1 ); if ( 'f' === $type && true === $this->allow_unsafe_unquoted_parameters - && 0 === substr_compare( $split_query[ $key - 1 ], '%', -1, 1 ) + && '%' === substr( $split_query[ $key - 1 ], -1, 1 ) ) { /* @@ -1623,7 +1623,7 @@ class wpdb { * Second, if "%s" has a "%" before it, even if it's unrelated (e.g. "LIKE '%%%s%%'"). */ if ( true !== $this->allow_unsafe_unquoted_parameters - || ( '' === $format && 0 !== substr_compare( $split_query[ $key - 1 ], '%', -1, 1 ) ) + || ( '' === $format && '%' !== substr( $split_query[ $key - 1 ], -1, 1 ) ) ) { $placeholder = "'%" . $format . "s'"; } diff --git a/wp-includes/version.php b/wp-includes/version.php index 47c8298d3d..577f54485b 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -16,7 +16,7 @@ * * @global string $wp_version */ -$wp_version = '6.2-alpha-55157'; +$wp_version = '6.2-alpha-55158'; /** * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.