-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
PHP 8.2 | Gutenberg is introducing deprecated callables into WP Core #44536
Comments
@jrfnl Is there any way the tests can be made to fail if there are such critical issues? It'd be great if continuous integration could help prevent these kind of errors. edit: I'm also wondering how a developer can check the logs. I don't see anything being logged in the github check - https://github.com/WordPress/wordpress-develop/actions/runs/3084932834/jobs/4987654678. |
Thanks for creating this issue and the great explanation.
I believe the use of
Switching the callables to
Agree. I'm happy to throw up 2 x patches (Core and a Gutenberg sync). Will do it ASAP |
@talldan Well, to start, it would help if the tests for the PHP code in GB would actually be run on PHP 5.6 up to PHP 8.2, instead of only being run on PHP 7.4.... 😢 See: #43333 (comment)
That's correct as you are looking in the wrong place, though I have to admit, it's on my pet peeve list that the PHPCompatibility workflow hasn't been set up to also show the issues in the logs. It's on my long term to-do list to get that fixed. For now, issues thrown by PHPCompatibility will only show as comments in the PR, but PHPCompatibility wouldn't pick up on the issues I reported here yet, as there is no release (yet) containing PHP 8.2 related sniffs. What I meant was to check the actual unit test run logs. The test runs for PHP 8.1 and PHP 8.2 (for WP Core) are still "allowed to fail" due to the sheer amount of issues which had to be fixed, but the logs will show the issues. So for this issue, you can see the errors in the actual unit test runs on PHP 8.2 here: https://github.com/WordPress/wordpress-develop/actions/runs/3084932812/jobs/4987657992#step:19:306 Hope that helps ? |
@ramonjd thank you for providing this context. Highlights again that we all need to be careful when copying over code patterns as they may not be appropriate for another class.
👍🏻
A comment is a good first step, but what about making the class (After all, we all know that plugins will try to do things if they can, no matter what we say in comments/docblocks - if they can't extend the class, we don't have that problem).
Much appreciated! Feel free to ping me if you want a review/approval. |
I don't see any issues here. Given that it'd be great to avoid the compat woes that exist for WP Theme JSON, I'm for it. cc @aristath and @andrewserong Patches incoming... ! In fact it was already raised by @costdev in the original backport PR |
Same here — so far I think the intention has been for the style engine classes to be mostly used internally in WordPress, and for public functions to be used as the entry point for other use cases, e.g. plugins and themes. But I believe Ari has had more of the plugin/theme use case in mind so might have some insights to add there, too. |
I suppose an option could be to run the tests on |
I am actively working, together with some other people, to get it down to zero and remove the |
As it was, results of PHPCS runs would only ever show inline in a commit code view/PR code view. This is confusing as people will often try to find an output log of the run in the GH Actions build log, not realizing the scan results are not available in the GH Actions log. This commit changes the steps in the GH Actions workflows for both the PHPCS run against the WordPress Coding Standards as well as for the run against PHPCompatibility to show the full scan results report in the GH Actions logs **_as well as_** show the results in commit/PR code views and still fail the build correctly when new issues are detected. I've elected to store the (temporary) `phpcs-report.xml` file in the `artifacts` subdirectory as that directory is (git/svn)-ignored by default already to prevent this new, temporary file from interfering with the `git diff` check at the end of the workflows. Refs: * https://github.com/staabm/annotate-pull-request-from-checkstyle#using-php_codesniffer * WordPress/gutenberg#44536 (comment)
As it was, results of PHPCS runs would only ever show inline in a commit code view/PR code view. This is confusing as people will often try to find an output log of the run in the GH Actions build log, not realizing the scan results are not available in the GH Actions log. This commit changes the steps in the GH Actions workflows for both the PHPCS run against the WordPress Coding Standards as well as for the run against PHPCompatibility to show the full scan results report in the GH Actions logs **_as well as_** show the results in commit/PR code views and still fail the build correctly when new issues are detected. I've elected to store the (temporary) `phpcs-report.xml` file in the `.cache` subdirectory as that directory is (git/svn)-ignored by default already to prevent this new, temporary file from interfering with the `git diff` check at the end of the workflows. Refs: * https://github.com/staabm/annotate-pull-request-from-checkstyle#using-php_codesniffer * WordPress/gutenberg#44536 (comment)
As it was, results of PHPCS runs would only ever show inline in a commit code view/PR code view. This is confusing as people will often try to find an output log of the run in the GH Actions build log, not realizing the scan results are not available in the GH Actions log. This commit changes the steps in the GH Actions workflows for both the PHPCS run against the WordPress Coding Standards as well as for the run against PHPCompatibility to show the full scan results report in the GH Actions logs **_as well as_** show the results in commit/PR code views and still fail the build correctly when new issues are detected. I've elected to store the (temporary) `phpcs-report.xml` file in the `.cache` subdirectory as that directory is (git/svn)-ignored by default already to prevent this new, temporary file from interfering with the `git diff` check at the end of the workflows. Note: I'm also removing the `-q` (quiet) flag from the PHPCS runs as it could give the misleading impression that nothing happened in the step for a successfull run. The progress report being shown will take away that impression. Refs: * https://github.com/staabm/annotate-pull-request-from-checkstyle#using-php_codesniffer * WordPress/gutenberg#44536 (comment)
|
As it was, results of PHPCS runs would only ever show inline in a commit code view/PR code view. This is confusing as people will often try to find an output log of the run in the GH Actions build log, not realizing the scan results are not available in the GH Actions log. This commit changes the steps in the GH Actions workflows for both the PHPCS run against the WordPress Coding Standards as well as for the run against PHPCompatibility to show the full scan results report in the GH Actions logs **_as well as_** show the results in commit/PR code views and still fail the build correctly when new issues are detected. I've elected to store the (temporary) `phpcs-report.xml` file in the `.cache` subdirectory as that directory is (git/svn)-ignored by default already to prevent this new, temporary file from interfering with the `git diff` check at the end of the workflows. Note: I'm also removing the `-q` (quiet) flag from the PHPCS runs as it could give the misleading impression that nothing happened in the step for a successfull run. The progress report being shown will take away that impression. Refs: * https://github.com/staabm/annotate-pull-request-from-checkstyle#using-php_codesniffer * WordPress/gutenberg#44536 (comment)
Copied over from https://core.trac.wordpress.org/ticket/56467#comment:242 for visibility
While looking at the test runs of WP Core, I've found that WP Core PR 3199 as committed in WP Core 54156 introduces four new incompatibilities with PHP 8.2.
The tests committed with that same PR are insufficient and did not flag the problem. The tests committed in WP Core 54211 luckily did flag the problem.
The problem is with the following code:
Each of these definitions use
'value_func' => 'static::get_individual_property_css_declarations'
.That syntax for declaring a callable is deprecated as of PHP 8.2 and will result in a fatal error as of PHP 9.0.
Changing this may require an architectural change to the class.
To explain:
'static::get_individual_property_css_declarations'
would bearray( static::class, 'get_individual_property_css_declarations' )
.static::class
cannot be used in a constant declaration as constant values have to be ''constant'' and howstatic::class
resolves can change at runtime depending on the class hierarchy.I'd like to understand why the choice was made to use
static::
in these declarations.I currently do not see any class within WP Core which extends the
WP_Style_Engine
class, so why isstatic::
being used instead ofself::
?As for solution directions:
static::
was not used intentional and can be replaced withself::
, the callables need to be rewritten toarray( self::class, 'get_individual_property_css_declarations' )
.static::
was used intentionally, an architectural change is needed as the callable cannot be declared like that in the constant.private
property without the callables and adding them to the array in the class constructor is not an option as the class only contains static methods and does not seem to be intended to be instantiated.private static
property is not an option either, as same as constants and non-static properties, the initial value for a property needs to be ''constant''.In other words: If
static::
was used intentionally, the class will probably need a rethink...As this is a new class and any architectural change in it in the future would be considered a breaking change, this MUST be fixed before WP 6.1 is released.
And for the love of code, please, please add better tests to safeguard against these kind of problems and check the PHP 8.1 and 8.2 test logs to prevent introducing new issues like this.
Also see: https://wiki.php.net/rfc/deprecate_partially_supported_callables
The text was updated successfully, but these errors were encountered: