mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2026-07-01 15:50:09 +00:00
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.
git-svn-id: https://develop.svn.wordpress.org/trunk@55158 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
@@ -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'";
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user