-
-
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
Fix API call params in updateAllMembershipStatus() #17992
Conversation
API implementation has changed to need contact_id. Otherwise it throws an error.
Can one of the admins verify this patch? |
(Standard links)
|
add to whitelist |
unrelated test fail |
@eileenmcnaughton Test fail looks like it could be related to me? |
@maynardsmith Do you know which PR changed the API signature? |
@mattwire re test - check all the other PRs over the last few hours.... It's a newish test that 'expired' as the membership dates stopped working |
@mattwire No sorry. I upgraded from 5.24 to 5.27.2 and then noticed the problem, but can't guarantee it was OK in 5.24 since we are just hitting our renewals season and there was so little activity before that. |
test this please |
@maynardsmith I think that you have hit an edge case bug rather than a change in api signature - we haven't had other reports despite people being obviously working on this. We did merge a couple of fixes recently - I would like to close this & seek more information |
@eileenmcnaughton OK, I may have made the wrong inference about the root cause of the problem, and/or applied the wrong fix. However, my observation stands, that in our system the Scheduled Job 'Update Membership Processes' (job.process_membership) is failing.
It is not obvious to me that we are doing anything that is not pretty standard, and am not sure what edge case we may be running into. The only possibility I can see is that we have renamed one Membership state, and introduced a custom one of our own, but with the change above that all works. What further information do you need? |
@maynardsmith - what were these "we have renamed one Membership state, and introduced a custom one of our own" Also - can you determine if it is stalling on a particular contact ? (I think the 2 patches merged were after 5.28.2 but one related to a scenario related to ma_related memberships - and the other was the alternate fix to the one you logged |
@eileenmcnaughton I don't think it's stalling on any particular contact. After upgrading to 5.28.2 on 31st August I forgot to reapply the patch and it just stopped processing any changes until today when I did so. |
There must be something else in play - as long as id is not empty contact_id is not required & the test testProcessMembershipUpdateStatus steps right through this code. The query to get id looks like this
Are you able to put in some debug / get a backtrace? |
In trying to interpret civicrm#17992 I realised that the code copies values from the dao to an array, copies the array to another array, unsets most of the variables and then uses that second array. This simplifies. The easiest way to work through this code is in a debugger running testProcessMembershipUpdateStatus
I opened this as a cleanup after digging through the code #18432 |
@eileenmcnaughton My cock-up I'm afraid. I have another routine in the Pre hook that is throwing the error. Nothing to do with the standard code. |
thanks for confirming @lalgwebdev |
Overview
API implementation for Create Membership has changed to need contact_id. Otherwise it throws an error. This causes the Scheduled Job to Update Membership Statuses to fail, unfortunately without notification.
Before
Scheduled Job to Update Membership Statuses fails. It reports that records have been updated, but no change actually occurs.
After
Job now works correctly.
Technical Details
The PR removes a line of code which removed contact_id from the API parameter list in updateAllMembershipStatus(). The comment says that this is to prevent possible race conditions with other parallel activity, but I don't see that there is a risk of the Contact Id also being altered.
The API Explorer says that both Contact Id and Membership Type Id are mandatory on this API call (Create Membership). However, previously the code functioned OK to update an existing Membership with just the Membership Id being supplied. Now it returns an error if the Contact Id is missing.
In our situation it still works without the Membership Type Id, but a Contact only ever has a single Membership, I don't know what happens if there are multiple Memberships. I can see a possible (if rare) race condition on Membership Type Id, so have left this unaltered.