General: Return early from `str_ends_with()` polyfill if both haystack and needle are empty.
Prior to PHP 7.0, `substr( '', -0, 0 )` returns `false` instead of an empty string, so the strict comparison further in the function did not work as expected. This commit addresses a test failure on PHP < 7.0, making the function consistently return `true` if both haystack and needle are an empty string. Follow-up to [52040], [56014], [56015]. See #58220. Built from https://develop.svn.wordpress.org/trunk@56016 git-svn-id: http://core.svn.wordpress.org/trunk@55528 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
848e8cbaec
commit
e0ffbee0aa
|
@ -482,8 +482,8 @@ if ( ! function_exists( 'str_ends_with' ) ) {
|
||||||
* @return bool True if `$haystack` ends with `$needle`, otherwise false.
|
* @return bool True if `$haystack` ends with `$needle`, otherwise false.
|
||||||
*/
|
*/
|
||||||
function str_ends_with( $haystack, $needle ) {
|
function str_ends_with( $haystack, $needle ) {
|
||||||
if ( '' === $haystack && '' !== $needle ) {
|
if ( '' === $haystack ) {
|
||||||
return false;
|
return '' === $needle;
|
||||||
}
|
}
|
||||||
|
|
||||||
$len = strlen( $needle );
|
$len = strlen( $needle );
|
||||||
|
|
|
@ -16,7 +16,7 @@
|
||||||
*
|
*
|
||||||
* @global string $wp_version
|
* @global string $wp_version
|
||||||
*/
|
*/
|
||||||
$wp_version = '6.3-alpha-56015';
|
$wp_version = '6.3-alpha-56016';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
||||||
|
|
Loading…
Reference in New Issue