-
Notifications
You must be signed in to change notification settings - Fork 218
Fix casting error on Utils::wp_version_compare #11802
Conversation
The release ZIP for this PR is accessible via:
Script Dependencies ReportThere is no changed script dependency between this branch and trunk. This comment was automatically generated by the TypeScript Errors Report
🎉 🎉 This PR does not introduce new TS errors. |
Size Change: 0 B Total Size: 1.61 MB ℹ️ View Unchanged
|
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.
@alefesouza Thank you for working on this! I tested with a patch version and the existing code looks like it's not set up to match patches. Since that seems expected, this PR LGTM.
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.
Thank you for working on this PR, @alefesouza! The regex is correct, but the version number that we should apply it to is the one we get from the get_bloginfo
. During my testing, I still encountered the same error. Perhaps we should consider applying a preg_replace
on line 25!
@tarhi-saad fixed on ef429f1. |
674b9d9
to
757409d
Compare
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.
Hey, @alefesouza! 👋 Thanks a lot for taking care of this! 🙌 I'll merge the PR after the CI checks are done! 🎉
What
Fixes #10563
Why
Fix casting error on
Utils::wp_version_compare
when using a different PHP locale.Testing Instructions
While testing with
version_compare
with the French locale I could reproduce the errors mentioned on #10563, it looks like it didn't affectUtils::wp_version_compare
method but as mentioned here: p1692776050961299/1692773342.122439-slack-C8X6Q7XQU it's fine to fix it defensively.php -a
setlocale(LC_ALL, 'fr_FR');
var_dump((float)6.4);
float(6,4)
(with the comma instead of dot), you need to install the fr_FR locale, for Docker you can run it on your container:require_once 'wp-load.php';
require 'wp-content/plugins/woo-gutenberg-products-block/src/Utils/Utils.php'
var_dump(\Automattic\WooCommerce\Blocks\Utils\Utils::wp_version_compare(6.4, '='));
, changing the parameters, all output should run as expected, to simulate WordPress version you can run:global $wp_version; $wp_version = '6.4.0';
WooCommerce Visibility
Required:
Checklist
Required:
[type]
label or a[skip-changelog]
label.Conditional:
[skip-changelog]
label is not present).