-
-
Notifications
You must be signed in to change notification settings - Fork 825
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
Don't use random parameters to detect if we should create MembershipPayment #14897
Conversation
(Standard links)
|
@mattwire needs a rebase |
dedbf76
to
b50fb6c
Compare
@eileenmcnaughton Now rebased :-) |
@MegaphoneJon I wonder if this is a piece of your puzzle on paypal |
Yes, this may have been the underlying bug that led to the issue. |
@MegaphoneJon Awesome if it is! I just came across it and thought, hmm that doesn't look very reliable.. |
$membershipPayment = civicrm_api3('MembershipPayment', 'get', [ | ||
'contribution_id' => $contribution->id, | ||
]); | ||
if (empty($membershipPayment['count'])) { |
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 guess a contribution could relate to more than one membership - so this might fail to create some
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.
@mattwire @MegaphoneJon I think the IF should go altogether - in fact - perhaps by accident -- in current master $ids['contribution'] is ALWAYS empty & also the membershipPayment.create code handles being called twice for the same pair
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.
@eileenmcnaughton When we reach this point we are working with a single specific membership ID, the entire function would be called once for each membership so contributions linked to multiple memberships would be ok.
If we remove the IF statement then we call hooks multiple times for membershippayment for no good reason, as if it already exists nothing has changed. So I'd prefer that the code checks before calling create in this instance.
Overview
Follow on from #14886
There are 3 places where a MembershipPayment may be created. This bit uses 2 unrelated parameters to check if we've already hit one of those other places. Instead, just check directly for a MembershipPayment using the API and don't rely on parameters which come from elsewhere and may change.
Before
Uses random parameters to decide whether a MembershipPayment should be created.
After
Use a proper check to decide whether a MembershipPayment should be created.
Technical Details
Described above.
Comments
@eileenmcnaughton Follow on from #14886 which should be merged first