Skip to content

WP 5.8 Backport: Introduce function wp_readonly() (Trac 53858) #1590

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed

Conversation

jrfnl
Copy link
Member

@jrfnl jrfnl commented Aug 16, 2021

Since PHP 8.1, readonly is a reserved keyword and cannot be used as a function name.

In order to avoid PHP parser errors, the readonly() function was extracted to a separate file and is now only included conditionally on PHP < 8.1 in WP 5.9.

To prevent plugins/themes using this function each having to polyfill it, the new wp_readonly() function is being backported.

Trac ticket: https://core.trac.wordpress.org/ticket/53858


This Pull Request is for code review only. Please keep all other discussion in the Trac ticket. Do not merge this Pull Request. See GitHub Pull Requests for Code Review in the Core Handbook for more details.

Since PHP 8.1, `readonly` is a reserved keyword and cannot be used as a function name.

In order to avoid PHP parser errors, the `readonly()` function was extracted to a separate file and is now only included conditionally on PHP < 8.1 in WP 5.9.

To prevent plugins/themes using this function each having to polyfill it, the new `wp_readonly()` function is being backported.
@jrfnl jrfnl changed the title WP 5.8 Backport: Introduce function wp_readonly() WP 5.8 Backport: Introduce function wp_readonly() (Trac 53858) Aug 16, 2021
Copy link
Contributor

@hellofromtonya hellofromtonya left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To prevent plugins/themes using this function each having to polyfill it, the new wp_readonly() function is being backported.

For this reason, i.e. making it easier on extenders, I agree this function should be backported 👍

@jrfnl
Copy link
Member Author

jrfnl commented Sep 14, 2021

I'm closing this PR as a change has been made (committed) to PHP 8.1, which mitigates the impact of the new readonly keyword, meaning that a backport should not be necessary anymore.

For more information, see: php/php-src#7468

@jrfnl jrfnl closed this Sep 14, 2021
@jrfnl jrfnl deleted the trac-53858/backport-of-wp_readonly branch September 14, 2021 21:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants