-
-
Notifications
You must be signed in to change notification settings - Fork 824
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
Allow to disable an invalid relationship (eg. contact subtype was changed so no longer valid) #25647
Allow to disable an invalid relationship (eg. contact subtype was changed so no longer valid) #25647
Conversation
(Standard links)
|
8ad0b2f
to
db855bd
Compare
Fail seems related:
|
Hmm, passes locally! |
test this please |
Hmm... |
db855bd
to
4c29834
Compare
…nged so no longer valid)
4c29834
to
00c49d2
Compare
It's the same test fail. Something is checking the relationship_type even when you're just trying to update is_active. Now, why it is checking "2" I haven't looked. Possibly this surfaces a different bug? |
Yep, it's looking for related memberships for an unrelated relationship that doesn't exist in the test environment... |
…le/disable relatedmemberships code
1759e72
to
798be50
Compare
…pToInheritMembershipType as it doesn't fail if relationship type IDs don't exist
798be50
to
bafcad8
Compare
Or two... |
if (!empty($params['id']) && array_key_exists('is_active', $params) && empty($params['is_active'])) { | ||
$disableRelationship = TRUE; | ||
} | ||
if (empty($disableRelationship) && !CRM_Contact_BAO_Relationship::checkRelationshipType($params['contact_id_a'], $params['contact_id_b'], $params['relationship_type_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.
Taking another look at this now but first noticing a non-blocking r-code comment:
The variable $disableRelationship can be undefined at line 63 and while php doesn't complain it just seems better to explicitly set it, and some fancy IDE's might nag about it.
- if (!empty($params['id']) && array_key_exists('is_active', $params) && empty($params['is_active'])) {
- $disableRelationship = TRUE;
- }
+ $disableRelationship = !empty($params['id']) && array_key_exists('is_active', $params) && empty($params['is_active']);
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 can you make this change?
@demeritcowboy if you use the suggestion
feature then it can be merged in with a click :)
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'll just merge and do a followup in a bit.
Overview
If you use (and change) contact sub-types it is easy to end up with invalid relationships that you can't do anything with.
It should be possible to disable these relationships without having to modify them (eg. a contact who had "Staff" subtype is changed to "Ex-Staff" subtype).
The relationship is now invalid according to CiviCRM but it is still correct from a historical data perspective. This also affects the "update expired relationships" scheduled job which can get stuck if it finds and invalid relationship.
Before
Invalid relationships can't be disabled..
After
Invalid relationships can be disabled.
Technical Details
Explained above. It would be nice to have a separate API call for disable so we don't have to have so much logic in ::create. But that would require changes to various parts of the API/UI etc. so out of scope for now.
Comments