-
-
Notifications
You must be signed in to change notification settings - Fork 829
(dev/core#1433) move post hook to avoid errors with custom fields created in the hook #16061
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
(Standard links)
|
CRM/Contribute/BAO/Contribution.php
Outdated
@@ -90,6 +90,8 @@ public static function add(&$params, $ids = []) { | |||
if (empty($params)) { | |||
return NULL; | |||
} | |||
$contributionID = CRM_Utils_Array::value('contribution', $ids, CRM_Utils_Array::value('id', $params)); |
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.
isn't this duplicating L96 and if so should the comment be moved up above this line and L96 removed?
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.
yep
@@ -512,14 +513,6 @@ public static function create(&$params, $ids = []) { | |||
throw $e; | |||
} | |||
|
|||
$params['contribution_id'] = $contribution->id; |
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.
It doesn't look to me that $params is picked up from self::add so maybe need this line still?
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.
or maybe it is but i'm just confuzzled
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 put it back - this is the rc & possibly a live patch so conservative is better
c14d119
to
f1c2ef0
Compare
…ed in the hook Per dev/core#1460 a fatal error can occur if custom data is created in the post hook. In addition I note it makes sense to include custom data before the rollback
f1c2ef0
to
80e74f7
Compare
I have tested this and confirmed it works and have generated a unit test #16063 to lock in the fix |
Shouldn't this be dev/core#1443 instead of dev/core#1460? |
@totten yes it should. Eileen and I have probably gotten turned around on the different lab tickets on hooks |
Overview
Fixes a regression from around 5.16 - Per dev/core#1460 a fatal error can occur if custom data is created in the post hook as we now assume we can INSERT on new contributions. From a WMF point of view the change significantly reduced deadlocks but it causes an issue if someone creates custom fields in the post hook and then also in the main flow as it is no longer new
Before
Install an extension with an implementation of hook_civicrm_post() that creates a custom value for a newly created entity
e.g.:
Try to create an entity of that type (UI or API)
Notice the error
After
No error
Technical Details
I think this makes sense - I only found 2 places that call add directly & I don't think they will be hurt however some testing on the main contribution page flow is needed as one is in 'Confim.php'.
I think makes sense to include custom data before the rollback
Comments