From 9b0ff7e223428ca0c143cf6cb6a4efc62cca2faa Mon Sep 17 00:00:00 2001 From: Eileen McNaughton Date: Tue, 8 Jun 2021 12:06:57 +1200 Subject: [PATCH] Sort trigger data before processing At some point these stopped being consistently alpha sorted - which doesn't matter if you are just letting Civi run the trigger updates but if you output it and diff it this inconsistency is a problem Subset of https://github.com/civicrm/civicrm-core/pull/20472 in the hope of getting this merged https://github.com/civicrm/civicrm-core/pull/20471 also grooms this output for diffing albeit only in an edge case --- CRM/Logging/Schema.php | 3 +++ Civi/Core/SqlTriggers.php | 4 ++++ 2 files changed, 7 insertions(+) diff --git a/CRM/Logging/Schema.php b/CRM/Logging/Schema.php index 4c6cb192b9..356aaf8fae 100644 --- a/CRM/Logging/Schema.php +++ b/CRM/Logging/Schema.php @@ -242,6 +242,9 @@ AND (TABLE_NAME LIKE 'log_civicrm_%' $nonStandardTableNameString ) $tableNames = $this->tables; } + // Sort the table names so the sql output is consistent for those sites + // loading it asynchronously (using the setting 'logging_no_trigger_permission') + asort($tableNames); foreach ($tableNames as $table) { $validName = CRM_Core_DAO::shortenSQLName($table, 48, TRUE); diff --git a/Civi/Core/SqlTriggers.php b/Civi/Core/SqlTriggers.php index 6fdc3336b7..de0b5a9de9 100644 --- a/Civi/Core/SqlTriggers.php +++ b/Civi/Core/SqlTriggers.php @@ -138,6 +138,10 @@ class SqlTriggers { } } + // Sort tables alphabetically in order to output in a consistent order + // for sites that like to diff this output over time + // (ie. with the logging_no_trigger_permission setting in place). + asort($triggers); // now spit out the sql foreach ($triggers as $tableName => $tables) { if ($onlyTableName != NULL && $onlyTableName != $tableName) { -- 2.25.1