[wp-trac] [WordPress Trac] #58220: Replace usage of substr with str_starts_with and str_ends_with
WordPress Trac
noreply at wordpress.org
Sat Jun 24 13:38:59 UTC 2023
#58220: Replace usage of substr with str_starts_with and str_ends_with
------------------------------+-----------------------------
Reporter: Soean | Owner: SergeyBiryukov
Type: enhancement | Status: closed
Priority: normal | Milestone: 6.3
Component: General | Version:
Severity: normal | Resolution: fixed
Keywords: has-patch commit | Focuses: performance
------------------------------+-----------------------------
Comment (by SergeyBiryukov):
In [changeset:"56016" 56016]:
{{{
#!CommitTicketReference repository="" revision="56016"
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.
}}}
--
Ticket URL: <https://core.trac.wordpress.org/ticket/58220#comment:22>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list