-
Notifications
You must be signed in to change notification settings - Fork 10.7k
Make sure payment gateway title is a string before sanitizing #33434
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
Conversation
barryhughes
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.
This looks good and it solves the issue in the stack-trace we saw; but it now makes me wonder about this related piece of code:
WC_Settings_API::validate_safe_text_field()
The $value it receives can also be null and so in principle the same problem could apply here.
Older methods take care of coercing the value to string in a manual fashion, perhaps we need to do the same (and drop the type-hinting in ::validate_safe_text_field(), unless we can always cast to string before passing to individual validation methods—not immediately sure if that could lead to other back-compat issues).
The above is related, but that doesn't mean we need to address it in this PR (since it's not triggering the fatal error we became aware of), but I wanted to pause, flag and get your thoughts ...
barryhughes
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.
Pre-emptively approving, because this looks good and works well: so, if we decide not to address the issue in my earlier comment, we can ship this ✅
|
📊 Test reports for this pull request have been published and are accessible through the following links:
Latest commit referenced in the reports: Visit the WooCommerce Test Reports homepage to view all published reports. See the FAQs page if you're having problems accessing them. |
|
Hey @barryhughes! Thanks for the quick review 💯.
I liked the type-hint but if the method can in fact receive a |
plugins/woocommerce/includes/abstracts/abstract-wc-settings-api.php
Outdated
Show resolved
Hide resolved
barryhughes
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.
Left a further note, but, it's an optional change. This looks good!
…i.php Co-authored-by: Barry Hughes <[email protected]>
|
Thanks @barryhughes! I've committed the suggested change. |
barryhughes
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.
LGTM: I'll keep an eye on the tests/checks and merge when done 👍
|
Hi @barryhughes, thanks for merging this pull request. Please take a look at these follow-up tasks you may need to perform:
|
All Submissions:
Changes proposed in this Pull Request:
This PR casts the gateway title to
stringbefore passing it through our new sanitizing methods to prevent possible fatal errors due to a type mismatch.This seems very unlikely to happen (with only one gateway detected so far that is affected).
How to test the changes in this Pull Request:
trunk.Other information:
pnpm changelog add --filter=<project>?FOR PR REVIEWER ONLY: