Skip to content
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

[REF] minor code cleanup - move indexExist calculation to the only place in the code that needs it #14650

Merged
merged 1 commit into from
Jun 28, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 6 additions & 8 deletions CRM/Core/BAO/CustomField.php
Original file line number Diff line number Diff line change
Expand Up @@ -175,12 +175,6 @@ public static function create(&$params) {
}
$columnName = $params['column_name'];

$indexExist = FALSE;
//as during create if field is_searchable we had created index.
if (!empty($params['id'])) {
$indexExist = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_CustomField', $params['id'], 'is_searchable');
}

switch (CRM_Utils_Array::value('html_type', $params)) {
case 'Select Date':
if (empty($params['date_format'])) {
Expand Down Expand Up @@ -315,6 +309,11 @@ public static function create(&$params) {
$triggerRebuild = CRM_Utils_Array::value('triggerRebuild', $params, TRUE);
//create/drop the index when we toggle the is_searchable flag
if ($op == 'edit') {
$indexExist = FALSE;
//as during create if field is_searchable we had created index.
if (!empty($params['id'])) {
$indexExist = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_CustomField', $params['id'], 'is_searchable');
}
self::createField($customField, 'modify', $indexExist, $triggerRebuild);
}
else {
Expand All @@ -327,8 +326,7 @@ public static function create(&$params) {
// make sure all values are present in the object
$customField->find(TRUE);

$indexExist = FALSE;
self::createField($customField, 'add', $indexExist, $triggerRebuild);
self::createField($customField, 'add', FALSE, $triggerRebuild);
}

// complete transaction
Expand Down