-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
Ensure WP_Text_Diff_Renderer_Table is PHP 8.2 compatible #5453
Ensure WP_Text_Diff_Renderer_Table is PHP 8.2 compatible #5453
Conversation
…sure compatbility with PHP 8.2. PHP 8.2 doesn't support dynamic properties.
* @since 6.4.0 | ||
* @var string|null | ||
*/ | ||
public $_title; |
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.
I intentionally didn't initialize these class properties because they used to be set to NULL
in the previous implementation. This is to maintain BC.
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.
Yes, I agree, the original default value of null
is being maintained.
Thank you, @anton-vlasenko, for the PR. Could you also include a brief description indicating that we added these variables for backward compatibility (BC)? This way, we can prevent someone from raising a ticket in the future to remove these variables, claiming they are unused. |
Thank you for checking this PR, @mukeshpanchal27!
If I understand you correctly, you're referring to this comment. These class properties weren't just declared to maintain BC. They were introduced to ensure compatibility with PHP 8.2. What I meant is that these properties are not assigned any value to ensure BC. In my opinion, this doesn't need to be explained in the code. But that's my opinion. |
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.
Core is using these 3 properties, which prior to this patch, were dynamic properties. With the changes to the magic methods, dynamic properties are deprecated for all PHP versions. Explicitly declaring these properties on the class is a follow-up to that scope of work and is needed.
Changes LTGM 👍 Ready for commit.
To follow-up on the discussion of these properties: Anton is right - they are not being declared on the class for BC. Rather, this patch is necessary to explicitly declare the properties that are being used in Core. Why? Prior to this patch, the properties were dynamic and thus were accessible only through the magic methods. r56354 modified the magic methods for all WP supported PHP versions (not just PHP 8.2+) to raise a deprecation for all dynamic properties. Core itself though should not be raising this new deprecation as it's properties should all be declared. |
I first reviewed this patch thinking - yes, let's add the properties as declared. But then looking at r56354 I remember the changes implemented uses the I wondering .. should these 3 properties also be added to the @anton-vlasenko @mukeshpanchal27 what do you think? |
@hellofromtonya I'm looking at https://core.trac.wordpress.org/ticket/56034 and, as far as I understand, the recommended way of dealing with known, named dynamic properties is to declare them on the class. |
@anton-vlasenko you're right. That is the recommended approach. Thanks for reminding me! I'm curious of the previous behavior, i.e. before r56354. Let's double check before moving forward with committing this change. |
Thank you, @hellofromtonya. |
Thanks @anton-vlasenko. Testing before and after for these Core specific dynamic properties:
So the PR as it is now aligns to that plan. |
Committed via https://core.trac.wordpress.org/changeset/56938. |
This PR aims to add missing class properties to ensure
WP_Text_Diff_Renderer_Table
is PHP 8.2 compatible.Trac ticket: https://core.trac.wordpress.org/ticket/59431
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.