Make WordPress Core

Opened 3 years ago

Closed 3 years ago

Last modified 3 years ago

#54377 closed feature request (fixed)

Introduce new PHP cross-version compatibility functions, `str_ends_with()`

Reported by: pbiron's profile pbiron Owned by: hellofromtonya's profile hellofromTonya
Milestone: 5.9 Priority: normal
Severity: normal Version:
Component: General Keywords: php8 has-patch has-unit-tests commit
Focuses: Cc:


PHP 8 added a str_ends_with() function.

It would be good to add a polypill for it to core, so that plugins that use it will work on sites running PHP < 8.

I'll do a patch with unit tests tomorrow.

Related: #45055, #49652

Change History (13)

#1 @hellofromTonya
3 years ago

  • Owner set to hellofromTonya
  • Status changed from new to accepted

Accepting this feature as it can be bundled with the other PHP polyfills.

This ticket was mentioned in Slack in #core-php by hellofromtonya. View the logs.

3 years ago

#3 @hellofromTonya
3 years ago

  • Keywords php8 added

#4 @pbearne
3 years ago

there is a str_starts_with()

#5 @pbiron
3 years ago

Thanx @pbearne! (hi, by the way :-)

I was just coming to add a comment that I will also include a polyfill for str_starts_with() as well.

This ticket was mentioned in PR #1811 on WordPress/wordpress-develop by pbearne.

3 years ago

  • Keywords has-patch has-unit-tests added; needs-patch needs-unit-tests removed

This ticket was mentioned in Slack in #core-php by pbearne. View the logs.

3 years ago

#8 @pbiron
3 years ago

@pbearne Thanx for the PR Paul. I just made a few comments/suggestions for corrections to it.

@hellofromTonya Would appreciate you also looking at those comments.

#9 @hellofromTonya
3 years ago

  • Keywords commit added

Thanks @pbiron for the ping. Did a thorough review. Ready for commit.

#10 @hellofromTonya
3 years ago

  • Resolution set to fixed
  • Status changed from accepted to closed

In 52040:

General: Introduce polyfills for str_ends_with() and str_starts_with() added in PHP 8.0.

PHP 8.0 introduced two new functions: str_ends_with() and str_starts_with(). These perform a case-sensitive check indicating if the string to search in (haystack) ends or begins with the given substring (needle).

These polyfills make these functios available for use in Core.


Props costdev, hellofromTonya, pbearne, pbiron.
Fixes #54377.

#12 @hellofromTonya
3 years ago

Thank you everyone for your contributions! These functions are now available for use in Core.

This ticket was mentioned in Slack in #core by sergey. View the logs.

3 years ago

Note: See TracTickets for help on using tickets.