-
-
Notifications
You must be signed in to change notification settings - Fork 14
WP 6.5/6.8/6.9: account for new function and constant polyfills #88
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
WP 6.5/6.8/6.9: account for new function and constant polyfills #88
Conversation
|
@rodrigoprimo Thanks for this PR. Could you please add links to the WP Trac tickets + changesets for each of these changes to the commit message + the PR description to justify these changes and to make reviewing this PR more straight-forward ?
Yes it should. Not sure why these are missing, could be that they are part of a larger RFC which hasn't been addressed yet, could be that PHP Core forgot to mention them in the UPGRADING guide/migration guide. Feel free to open a PR, but please be aware that this will need tracing the changes back to their origins in PHP Core repo to justify the changes.
Ah, yes, those WP polyfills are laughable as they a) shouldn't exist, b) never polyfill on any known PHP version, so are completely redundant until PHP 9.0 would be released.... Agreed to not exclude the error message related to those. |
I checked the WordPress src/wp-includes/compat.php file for new polyfills that should be added and here is what I found that was missing in this repository: WP 6.5 added polyfills for: * `IMAGETYPE_AVIF` and `IMG_AVIF` constants, which were introduced in PHP 8.1. See https://core.trac.wordpress.org/ticket/51228 and https://core.trac.wordpress.org/changeset/57524. WP 6.8 added polyfills for: * `array_find()`, `array_find_key()`, `array_any()` and `array_all()`, which were introduced in PHP 8.4. See https://core.trac.wordpress.org/ticket/62558 and https://core.trac.wordpress.org/changeset/59783. WP 6.9 added polyfills for: * `array_first()` and `array_last()`, which were introduced in PHP 8.5. See https://core.trac.wordpress.org/ticket/63853 and https://core.trac.wordpress.org/changeset/60672. * `IMAGETYPE_HEIF` constant, which was introduced in PHP 8.5. See https://core.trac.wordpress.org/ticket/64322 and https://core.trac.wordpress.org/changeset/61328. Note: The `IMAGETYPE_AVIF` and `IMAGETYPE_HEIF` constants are not yet flagged by PHPCompatibility. Since excluding error codes that don't exist yet doesn't trigger errors in PHPCS, we may as well add the exclusions proactively. Unless I'm missing something, I believe PHPCompatibility should be updated to check for these constants. Note: WP 6.9 also added polyfills for `utf8_encode()` and `utf8_decode()`, which were deprecated in PHP 8.2 and will be removed in PHP 9.0. These are intentionally not excluded here, as these functions are deprecated and developers should migrate to `mb_convert_encoding()`. My understanding is that the WordPress polyfill exists for backward compatibility with legacy code, but PHPCompatibility should still warn about their usage.
3b95d2c to
ba2fbbd
Compare
|
Thanks for your feedback, @jrfnl!
Done
Here is the PR PHPCompatibility/PHPCompatibility#2022 |
jrfnl
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for this @rodrigoprimo !
I checked the WordPress
src/wp-includes/compat.phpfile for new polyfills that should be added, and here is what I found that was missing in this repository:WP 6.5 added polyfills for:
IMAGETYPE_AVIFandIMG_AVIFconstants, which were introduced in PHP 8.1. See https://core.trac.wordpress.org/ticket/51228 and https://core.trac.wordpress.org/changeset/57524.WP 6.8 added polyfills for:
array_find(),array_find_key(),array_any()andarray_all(), which were introduced in PHP 8.4. See https://core.trac.wordpress.org/ticket/62558 and https://core.trac.wordpress.org/changeset/59783.WP 6.9 added polyfills for:
array_first()andarray_last(), which were introduced in PHP 8.5. See https://core.trac.wordpress.org/ticket/63853 and https://core.trac.wordpress.org/changeset/60672.IMAGETYPE_HEIFconstant, which was introduced in PHP 8.5. See https://core.trac.wordpress.org/ticket/64322 and https://core.trac.wordpress.org/changeset/61328.Note: The
IMAGETYPE_AVIFandIMAGETYPE_HEIFconstants are not yet flagged by PHPCompatibility. Since excluding error codes that don't exist yet doesn't trigger errors in PHPCS, we may as well add the exclusions proactively. Unless I'm missing something, I believe PHPCompatibility should be updated to check for these constants. I can prepare a PR for PHPCompatibility to start checking for those constants if that helps.Note: WP 6.9 also added polyfills for
utf8_encode()andutf8_decode(), which were deprecated in PHP 8.2 and will be removed in PHP 9.0. These are intentionally not excluded here, as these functions are deprecated and developers should migrate tomb_convert_encoding(). My understanding is that the WordPress polyfill exists for backward compatibility with legacy code, but PHPCompatibility should still warn about their usage.Previous PR updating the list of polyfills: #55