-
-
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
Make savedSearch bao sane #16575
Make savedSearch bao sane #16575
Conversation
(Standard links)
|
bb50213
to
57fe3c4
Compare
@@ -290,7 +290,7 @@ public function testgetRecipientsEmailGroupIncludeExclude() { | |||
} | |||
else { | |||
$groupIDs[$i] = $this->smartGroupCreate([ | |||
'formValues' => ['last_name' => (($i == 6) ? 'smart5' : 'smart' . $i)], | |||
'form_values' => ['last_name' => (($i == 6) ? 'smart5' : 'smart' . $i)], |
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 think we should add an api alias to the v3 api so that formValues still works - since that's how we roll with v3 - it's just adding to the spec
$spec['form_values']['api.aliases'] = ['formValues'];
& the test would be that the above change would not be needed - acutally that's only true if the above calls apiv3 but 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.
@eileenmcnaughton I've added the api alias although formValues
was never officially supported by the api; the api expected form_values
, so I've just pushed that expectation down to the BAO as well.
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.
cool
@colemanw test fails relate - I think the field serialization can be defined in he xml |
57fe3c4
to
0be6762
Compare
Oh cool. Right, if I pass |
@colemanw am I right in thinking that the idea of saving an api savedSearch is tangental to api smart groups - in the sense that they might be leveraged by smart groups but we would also be able to save an api search WITHOUT a smart group - e.g for an entity that does not relate to contacts. I don't have a specific use case but it feels more logical & powerful if 'any' api search can be saved |
0be6762
to
8e5675f
Compare
This looks generally good - once tests are passing I'll check it more carefully but it looks like the right changes to clean this up to me |
8e5675f
to
85d3be3
Compare
@@ -515,7 +515,7 @@ public static function createSmartGroup(&$params) { | |||
if (isset($ssParams['saved_search_id'])) { | |||
$ssParams['id'] = $ssParams['saved_search_id']; | |||
} | |||
|
|||
$params['form_values'] = $params['formValues']; |
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.
This function is only ever called from the unit tests! We could probably move it over to the test class
85d3be3
to
617bec7
Compare
I was a bit mystified why there seem to be so few calls to this create function - it seems the code is here civicrm-core/CRM/Contact/Form/Task/SaveSearch.php Lines 166 to 189 in 34634ee
Maybe once we have the v4 api for saved search maybe we can update the form to use it! |
So my digging says the BAO function is only called by the tests in core! I think this is good to merge if the tests pass this time but we should do some follow ups |
Overview
Makes the savedSearch create function act in a more standard way so that tests pass and the APIv4 can use it.
Before
BAO create would overwrite values on update for no reason I can fathom. It also tries to save a non-existent field (
is_active
was removed in v1.5!) which doesn't give me much confidence that it was doing these things for a good reason.After
Make it act like a normal bao create function.