mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2025-10-16 12:05:38 +00:00
Database: Replace str_ends_with() usage in wpdb::prepare().
This avoids a fatal error if the file is included directly outside of WordPress core, e.g. by HyperDB. While WordPress core does include a polyfill function, it is not directly loaded in the `wpdb` class. This commit replaces the `str_ends_with()` calls with `substr_compare()` for now. Follow-up to [55151]. Props Otto42. See #52506. git-svn-id: https://develop.svn.wordpress.org/trunk@55157 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
parent
999f02218b
commit
d64680e98d
@ -1561,7 +1561,9 @@ class wpdb {
|
||||
$format = substr( $placeholder, 1, -1 );
|
||||
$type = substr( $placeholder, -1 );
|
||||
|
||||
if ( 'f' === $type && true === $this->allow_unsafe_unquoted_parameters && str_ends_with( $split_query[ $key - 1 ], '%' ) ) {
|
||||
if ( 'f' === $type && true === $this->allow_unsafe_unquoted_parameters
|
||||
&& 0 === substr_compare( $split_query[ $key - 1 ], '%', -1, 1 )
|
||||
) {
|
||||
|
||||
/*
|
||||
* Before WP 6.2 the "force floats to be locale-unaware" RegEx didn't
|
||||
@ -1620,7 +1622,9 @@ class wpdb {
|
||||
* First, "numbered or formatted string placeholders (eg, %1$s, %5s)".
|
||||
* Second, if "%s" has a "%" before it, even if it's unrelated (e.g. "LIKE '%%%s%%'").
|
||||
*/
|
||||
if ( true !== $this->allow_unsafe_unquoted_parameters || ( '' === $format && ! str_ends_with( $split_query[ $key - 1 ], '%' ) ) ) {
|
||||
if ( true !== $this->allow_unsafe_unquoted_parameters
|
||||
|| ( '' === $format && 0 !== substr_compare( $split_query[ $key - 1 ], '%', -1, 1 ) )
|
||||
) {
|
||||
$placeholder = "'%" . $format . "s'";
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user