Page MenuHomePhabricator

WMFDonor updates in WMF Thank you are unexpected
Open, Needs TriagePublic

Description

We saw a deadlock where it was trying to update WMFDonor fields when sending a thank you. This feels unexpected & suggests either

  1. we are doing an unnecessary update or
  2. it is so hard on the heels of the insert it is tripping over it

The remedy depends which but as a first step I'm going to make the output a bit clearer

Event Timeline

Change #1172134 had a related patch set uploaded (by Eileen; author: Eileen):

[wikimedia/fundraising/crm@master] Use apiv4 in updateWMFDonorLastDonation

https://gerrit.wikimedia.org/r/1172134

Change #1172135 had a related patch set uploaded (by Eileen; author: Eileen):

[wikimedia/fundraising/crm@master] Update Contribution.get api call to v4

https://gerrit.wikimedia.org/r/1172135

So what seems to be happening is that we have 2 records created when a contribution is created

  • Contribution
  • ContributionExtra

They are created in that order so when the Contribution::post hook runs it can't grab the values correctly from contribution_extra & potentially 'guesses' them at the USD version (which is right more often than not).

Then *something* does another update - triggering the calc post the original_currency / original_amount having been saved - the odd thing is that 'something' is in the thank you job / not the donation processing job.

The code DOES seem to need some clean up before this can be fully worked through

The TY job updates the thankyou_date on civicrm_contribution after each send - I'd imagine this is what's triggering the post hook. Maybe that post hook can do an early return when it sees that the altered fields don't include anything amount-related?

Change #1172134 merged by jenkins-bot:

[wikimedia/fundraising/crm@master] Use apiv4 in updateWMFDonorLastDonation

https://gerrit.wikimedia.org/r/1172134

Change #1172135 merged by jenkins-bot:

[wikimedia/fundraising/crm@master] Update Contribution.get api call to v4

https://gerrit.wikimedia.org/r/1172135

The think is I think there IS an early return in there - so it is not being updated on the original create & is being left until the TY job - probably we need to take action when the custom data is updated rather than the contribution

Part of the issue is this test:

&& substr($contribution->receive_date, 0, 8) === date('Ymd')

On create the receive_date comes in as e.g. 20250729010101, but on edit it comes in as 2025-07-29 01:01:01