This repository has been archived by the owner on Feb 23, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 219
Check that the callback for filtering payment methods is available and is a function before trying to run it #7377
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
opr
added
status: needs review
type: bug
The issue/PR concerns a confirmed bug.
focus: blocks
Specific work involving or impacting how blocks behave.
block: cart
Issues related to the cart block.
block: checkout
Issues related to the checkout block.
labels
Oct 12, 2022
rubikuserbot
requested review from
a team and
alexflorisca
and removed request for
a team
October 12, 2022 12:17
The release ZIP for this PR is accessible via:
|
Size Change: +12 B (0%) Total Size: 962 kB
ℹ️ View Unchanged
|
alexflorisca
approved these changes
Oct 12, 2022
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.
Looks good 👍 . There were some checkout related e2e test failures, but I don't think they're related. I've re-run them just in case
github-actions
bot
added
status: ready to merge
and removed
status: needs review
labels
Oct 12, 2022
wavvves
pushed a commit
that referenced
this pull request
Oct 12, 2022
…d is a function before trying to run it (#7377) * Check callback for payment method is available before trying to run it * Check if callback is a function before trying to run it * Update tests to ensure callbacks only run if they are registered
Yeahhhh :) I noticed it almost four months ago but stayed in our backlog as we shifted focus. https://github.com/woocommerce/woocommerce-conditional-shipping-and-payments/issues/531 I'm happy that it got solved, tested it right now with both Conditional Shipping and Payments and Deposits, filtering out a gateway. No more errors in the console :) |
sunyatasattva
pushed a commit
that referenced
this pull request
Oct 26, 2022
…d is a function before trying to run it (#7377) * Check callback for payment method is available before trying to run it * Check if callback is a function before trying to run it * Update tests to ensure callbacks only run if they are registered
senadir
pushed a commit
to senadir/woocommerce-blocks
that referenced
this pull request
Nov 12, 2022
…d is a function before trying to run it (woocommerce#7377) * Check callback for payment method is available before trying to run it * Check if callback is a function before trying to run it * Update tests to ensure callbacks only run if they are registered
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Labels
block: cart
Issues related to the cart block.
block: checkout
Issues related to the checkout block.
focus: blocks
Specific work involving or impacting how blocks behave.
type: bug
The issue/PR concerns a confirmed bug.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
When registering callbacks to filter payment methods we have checks in place to ensure that (at the time of registration) the callbacks provided are functions. When deciding which payment methods to run callbacks for, we only check that any namespace has registered a callback for that method.
For example, consider the following list of registered payment method callbacks:
When we check whether any callbacks are registered for
paypal
, because we use.some
(which is the correct way to do it) we find out that they are, so the code incanMakePaymentWithExtensions
will run and try to execute the callback for the payment method in each namespace without checking whether the callback exists and is a function.This PR adds a check to ensure the callback we are trying to execute exists and is a function.
Testing
Automated Tests
User Facing Testing
Error when executing callback for cheque in some-extension-name TypeError: namespacedCallbacks[namespace] is not a function
.Denver
and ensure the Cash on Delivery method is not available.WooCommerce Visibility
Changelog