-
-
Notifications
You must be signed in to change notification settings - Fork 817
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
Respect pre hook for relationship to alter id in $params #12834
Conversation
@@ -316,7 +316,7 @@ public static function add(&$params, $ids = array(), $contactId = NULL) { | |||
$relationship->contact_id_b = $params['contact_id_b']; | |||
$relationship->contact_id_a = $params['contact_id_a']; | |||
$relationship->relationship_type_id = $type; | |||
$relationship->id = $relationshipId; | |||
$relationship->id = $params['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.
@pradpnayak I worry that this isn't robust & could be changed at any point, breaking any extensions that rely on it, since there is no specific contract / commitment to permitting id to be altered. 2 ways to protect it are
- by using code practices as standardised as possible - in this case perhaps merge in the defaults first & then do per code comment
//@todo this code needs to be updated for the possibility that not all fields are set
// by using $relationship->copyValues($params);
- unit tests
@totten @colemanw what do you think of this - I get why people would want it - but it seems to be ad hoc expanding our hook support contract (I don't think this is the first place that has been done but the concern still applies) - perhaps we need a generic syntax conformance test & to add it as a standard rather than an ad hoc approach. Note that adding Syntax conformance doesn't mean making it work for EVERY entity - it means doing the easy ones & setting the others to be skipped |
IMO this is consistent with other places in our codebase where we are working to deprecate the |
jenkins test this please |
I'm going to merge based on @colemanw's review - my caution remains that this handling of $params['id'] is not locked in by tests or by our hook contract & could change at any time so extensions that rely on it need to implement their own unit testing to warn them if it does change |
Overview
If we alter the $params['id'] in pre hook then its not respected by CRM_Contact_BAO_Relationship::add() function. This PR allows hook to alter id.