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

Schema handler fixes #18932

Merged
merged 2 commits into from
Nov 6, 2020
Merged

Schema handler fixes #18932

merged 2 commits into from
Nov 6, 2020

Conversation

colemanw
Copy link
Member

@colemanw colemanw commented Nov 5, 2020

Overview

Updates and a minor bug fix to custom field saving.

Before

Unused function hanging around.
Wrong param passed to fixSchemaDifferencesFor().
Overly complicated optimization that may have actually been less efficient.

After

Cleaner.

This cleans up the tableName lookup to use the method used throughout this class.
The extra optimization (local caching in the $tables variable) was actually less efficient
because CRM_Core_DAO::getFieldValue caches its results, and is used elsewhere so the value
is likely to already be cached.

The bug is that the same table name was repeatedly being passed into $logging->fixSchemaDifferencesFor().
@civibot
Copy link

civibot bot commented Nov 5, 2020

(Standard links)

@civibot civibot bot added the master label Nov 5, 2020
@@ -145,7 +137,7 @@ public static function bulkSave($bulkParams, $defaults = []) {
$logging->fixSchemaDifferencesFor($tableName, ['ADD' => $addedColumns[$tableName]]);
}

Civi::service('sql_triggers')->rebuild($params['table_name'], TRUE);
Civi::service('sql_triggers')->rebuild($tableName, TRUE);
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@eileenmcnaughton this looks like it was a real bug to me.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes - it would have only updated one - probably in practice that was enough

* @return bool
*/
public static function alterFieldSQL($params, $indexExist = FALSE, $triggerRebuild = TRUE) {
CRM_Core_Error::deprecatedFunctionWarning('function no longer in use / supported');
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep - deprecated Jul 2019

@eileenmcnaughton
Copy link
Contributor

Cover in testBulkCreate() is adequate here & code makes sense so as long as tests pass all good

@colemanw colemanw merged commit 52bea0d into civicrm:master Nov 6, 2020
@colemanw colemanw deleted the schemaHandler branch November 6, 2020 00:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants