From 0783feeeca2d6afb0c556a1fdc8150543038fbf6 Mon Sep 17 00:00:00 2001 From: Sergey Biryukov Date: Sat, 24 Jun 2023 13:00:15 +0000 Subject: [PATCH] General: Replace `substr_compare()` usage in the `str_ends_with()` polyfill. This avoids 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 [52040], [55158], [55990], [56014]. See #58220. git-svn-id: https://develop.svn.wordpress.org/trunk@56015 602fd350-edb4-49c9-b593-d223f7449a82 --- src/wp-includes/compat.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/wp-includes/compat.php b/src/wp-includes/compat.php index f9df28eac9..38ae725e93 100644 --- a/src/wp-includes/compat.php +++ b/src/wp-includes/compat.php @@ -488,7 +488,7 @@ if ( ! function_exists( 'str_ends_with' ) ) { $len = strlen( $needle ); - return 0 === substr_compare( $haystack, $needle, -$len, $len ); + return $needle === substr( $haystack, -$len, $len ); } }