mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2026-06-28 14:20:15 +00:00
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. git-svn-id: https://develop.svn.wordpress.org/trunk@56016 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
@@ -482,8 +482,8 @@ if ( ! function_exists( 'str_ends_with' ) ) {
|
||||
* @return bool True if `$haystack` ends with `$needle`, otherwise false.
|
||||
*/
|
||||
function str_ends_with( $haystack, $needle ) {
|
||||
if ( '' === $haystack && '' !== $needle ) {
|
||||
return false;
|
||||
if ( '' === $haystack ) {
|
||||
return '' === $needle;
|
||||
}
|
||||
|
||||
$len = strlen( $needle );
|
||||
|
||||
Reference in New Issue
Block a user