-
-
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
dev/core#1093 add a bulkCreate action for many customFields in one go #14694
Conversation
(Standard links)
|
aa7555a
to
7084881
Compare
7084881
to
a6abf77
Compare
76df6f6
to
861d07d
Compare
4238cc4
to
0c62271
Compare
This needs rebasing |
0c62271
to
1cc807f
Compare
rebased |
Api4 signature could look like this: civicrm/org.civicrm.api4#180 |
@eileenmcnaughton looks like a brittle test fell over on a whitespace change made in this PR:
|
1cc807f
to
9cbea12
Compare
6b874d1
to
b78a8a1
Compare
@colemanw now all the preliminary refactoring is done this is pretty simple - I have renamed it to bulkSave per your recommendation |
b78a8a1
to
473f059
Compare
test this please |
473f059
to
94472dd
Compare
@colemanw we are down to one unrelated fail here! |
$params = [ | ||
'table_name' => CRM_Core_DAO::getFieldValue('CRM_Core_DAO_CustomGroup', $field->custom_group_id, 'table_name'), | ||
]; | ||
$sql = str_repeat(' ', 8); |
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.
????????
<?php
echo str_repeat('?', 8);
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.
yeah weird but retained from 'create'
CRM/Core/BAO/CustomField.php
Outdated
$params = array_merge($defaults, $fieldParams); | ||
$operation = empty($params['id']) ? 'add' : 'modify'; | ||
$customField = self::createCustomFieldRecord($params); | ||
// Only doing 'add' for now - so hard coded & no indexExists. |
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.
What would it take to get this working with update? Then it would be ready for api4.
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.
oh - I think I mostly altered it but not in this spot - will fix
c2b9d75
to
0638164
Compare
The updates the way we add bulk fields to custom tables. It uses work I did upstream civicrm/civicrm-core#14694 and ported here https://gerrit.wikimedia.org/r/#/c/wikimedia/fundraising/crm/civicrm/+/520665/ to consolidate DB changes into a single sql call This took about 25 mins on staging to add 'all the fields' but note that this change does not add those fields as yet Update field add Bug: T170972 Change-Id: Ifabe56b4d9956d5a42a03948db20385ab51832f4
0638164
to
f928673
Compare
This function is only used by one place and feels like the wrong separation of concerns - ie we have a single create action & a multiple create action. They both need to share the generation of the sql to run but can handle the batching of that & rebuilding of triggers etc separately
b303735
to
d49c025
Compare
Add bulkCreate function for CustomField with a view towards this being a new protocol for how bulk create actions would look from a code POV which we could expose via apiv4
d49c025
to
e5ce15c
Compare
@colemanw it passed! (& test cover was good - I couldn't sneak anything past it) |
@@ -295,7 +295,7 @@ public static function buildForeignKeySQL($params, $separator, $prefix, $tableNa | |||
* @return bool | |||
*/ | |||
public static function alterFieldSQL($params, $indexExist = FALSE, $triggerRebuild = TRUE) { | |||
|
|||
CRM_Core_Error::deprecatedFunctionWarning('function no longer in use / supported'); |
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.
Probably should add a @deprecated
annotation too.
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.
Ok - I'll add that to the last PR (rather than invalidate tests on this)
Code & test coverage looks good. Merging. |
…y (ish) I have worked to extract functions upstream to support 'create' and 'bulkCreate' with a view to api support. civicrm#14694 This backports the additional functions to support bulk create (all changes to make this not a duplication of code are upstream but not in this port since it would make this a crazy complex & risky backport) Change-Id: Id437f335d122c993ca6b94d04bd7048c89f991e7
Overview
Add bulkCreate function for CustomField with a view towards this being a new protocol for how bulk create actions would look from a code POV which we could expose via apiv4
Before
No function for efficiently creating multiple fields
After
Function exists. There is a view to expose this via apiv4 but at this stage that has been left off to allow 'maturing' - unit test added
Technical Details
Preliminary cleanup changes are split off into smaller commits
#14705
#14697
#14693 (merged)
#14689 (merged)
Comments
I haven't switched Utils_Migrate to use the bulk action but that is the next logical step since it is kinda creating complexity to do 'bulk-action-lite'
https://lab.civicrm.org/dev/core/issues/1093