-
Notifications
You must be signed in to change notification settings - Fork 17
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
Fix known compatibility issues with PHP 7.4 #225
Conversation
Codecov Report
@@ Coverage Diff @@
## master #225 +/- ##
============================================
+ Coverage 40.82% 40.83% +<.01%
+ Complexity 13447 13445 -2
============================================
Files 367 367
Lines 51277 51275 -2
============================================
Hits 20936 20936
+ Misses 30341 30339 -2
Continue to review full report at Codecov.
|
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.
Laurence, I know this is unlikely to cause any breaking changes but are you able to test the functionality of the wc_rgb_from_hex()
function after changing the braces? The wiki (https://wiki.php.net/rfc/deprecate_curly_braces_array_access) is quite vague in terms of potential impact but does suggest that there are differences between the two.
Are there any other instances where { }
are used instead of [ ]
?
Would this script help https://gist.github.com/theodorejb/763b83a43522b0fc1755a537663b1863 ?
I have done manual checks for the plugin as an ordinary user since this converts colors. I am open you to suggesting other ways of testing.
I think this is an open door to #194 as a wider issue. I see this a quick solution to the fatal error coming right now. We cannot guess what version a user will be seeing hosts are allowing PHP 7.4 to run on servers.
Bash is not my forte but I don't see any other breaking lines via the automated 7.4 travis build. This particular issue arises from |
That's fine. That's what I was looking for.
This PR is dealing with a specific PHP7.4 issue as the title and description suggest. I agree it's part of #194 but that in itself is likely to get broken down into several PRs - like this one. So I think checks for other instances of
It's actually a PHP script but if you're saying that Travis is already checking for this and not reporting any errors then we should already be covered. Might also be worth trying to run that script on a backup copy of CC using PHP 7.4. Just for fun 🙂 |
Cherry-pick of woocommerce/woocommerce@7a7151bd44 to Classic Commerce.
This commit simply updates the PHP 7.4 version that is used in Travis now that PHP 7.4 has been officially released. Previously we were using RC versions to test the upcoming release. Cherry-pick of woocommerce/woocommerce@1ce283e to Classic Commerce. This commit also removes PHP 7.4 as an allowable failure on Travis.
…post object. Prevents Notices of Trying to access array offset on value of type bool because $src variables will be false. Cherry-pick of woocommerce/woocommerce@0d5c69712 to Classic Commerce.
Remove call to get_magic_quotes_runtime() as this function is deprecated as of PHP 7.4 (see https://wiki.php.net/rfc/deprecations_php_7_4). This part of the code was only needed for PHP <= 5.3 and this version is not supported anymore by WooCommerce. Cherry-pick of woocommerce/woocommerce@1f69fbcf3 to Classic Commerce.
This PR still needs some checks. One error still raise when activating the plugin and setting up using the wizard. |
@bahiirwa which error is that? Note I pushed some commits, with the goal of addressing all PHP 7.4 changes in this PR. There aren't very many. |
… PHP 7.4 Cherry-pick of woocommerce/woocommerce@d685964df to Classic Commerce.
Cherry-pick of woocommerce/woocommerce@1c47315b8 to Classic Commerce.
This allows us to check for PHP 7.4 compatibility even though ClassicPress hasn't released a fully compatible version yet.
There's no difference between
I do not see any other instances of accessing an array like this:
I looked for further PHP 7.4 compatibility commits using the following commands (your remote name may be different than
The error reported by @bahiirwa above did not appear in this list, but I found a relevant commit here: woocommerce/woocommerce@1c47315b8 Since there was at least 1 PHP notice-related commit where the Woo team did not write
|
Short version of the above comment: I think this is ready for beta1 but there may still be more to be done regarding full PHP 7.4 compatibility. |
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.
This is great work y'all. Just a couple of comments:
- @bahiirwa could you please take a quick look at the commits @nylen mentions in Fix known compatibility issues with PHP 7.4 #225 (comment). As James says, there may be nothing here, but while we're looking for 7.4 compat issues, it would be good to get that bit boxed off.
- Does commit e7d0541 do anything? It seems only to apply to file
includes/tracks/events/class-wc-settings-tracking.php
which does not exist in CC
Thanks again both. Good work.
Not sure what you had in mind but I think this could probably wait for a separate issue/PR. Even though nothing else jumped out at me as "definitely a PHP 7.4 issue", there is potentially quite a bit to look through, and so it might be good to organize that a little better.
I did |
|
I think with James' comments, this is green to go if you agree with the changes as well. Tests:
|
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.
All seems good.
All Submissions:
Changes proposed in this Pull Request:
Fix curly brackets fatal error [and other notices/warnings/errors] in PHP 7.4
PHP used to allow both square brackets and curly braces to be used interchangeably for accessing array elements and string offsets. The curly bracket syntax is only allowed in a limited set of cases and can be confusing for people not used to it.
PHP 7.4 will deprecate the curly brace syntax for accessing array elements and string offsets and it is expected that support will be completely removed in PHP 8.0.
Ref: https://wiki.php.net/rfc/deprecate_curly_braces_array_access
See https://core.trac.wordpress.org/ticket/47751.
Closes #194.
How to test the changes in this Pull Request:
Screenshot - before:
Screenshot - after: