From 912511a359680eb72b15c595b5091fa03f8687f2 Mon Sep 17 00:00:00 2001 From: Seamus Lee Date: Tue, 24 Dec 2019 10:41:08 +1100 Subject: [PATCH] dev/core#1489 do not reconcile managed entities whilst in upgrade mode and add in a step at the end of the upgrade process to reconcile managed entiies and add in civicrm_permissions hook to the whitelist of upgrade friendly hooks --- CRM/Core/ManagedEntities.php | 7 ++++++- CRM/Upgrade/Form.php | 2 ++ CRM/Utils/Hook.php | 2 +- 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/CRM/Core/ManagedEntities.php b/CRM/Core/ManagedEntities.php index a388328696..cf47fa6918 100644 --- a/CRM/Core/ManagedEntities.php +++ b/CRM/Core/ManagedEntities.php @@ -112,10 +112,15 @@ class CRM_Core_ManagedEntities { /** * Identify any enabled/disabled modules. Add new entities, update * existing entities, and remove orphaned (stale) entities. + * @param bool $ignoreUpgradeMode * * @throws Exception */ - public function reconcile() { + public function reconcile($ignoreUpgradeMode = FALSE) { + // Do not reconcile whilst we are in upgrade mode + if (CRM_Core_Config::singleton()->isUpgradeMode() && !$ignoreUpgradeMode) { + return; + } if ($error = $this->validate($this->getDeclarations())) { throw new Exception($error); } diff --git a/CRM/Upgrade/Form.php b/CRM/Upgrade/Form.php index 8c23bbbb03..4d9f5ea5f5 100644 --- a/CRM/Upgrade/Form.php +++ b/CRM/Upgrade/Form.php @@ -794,6 +794,8 @@ SET version = '$version' // Rebuild all triggers and re-enable logging if needed $logging = new CRM_Logging_Schema(); $logging->fixSchemaDifferences(); + + CRM_Core_ManagedEntities::singleton(TRUE)->reconcile(TRUE); } /** diff --git a/CRM/Utils/Hook.php b/CRM/Utils/Hook.php index b84ec7ac87..1491da33e2 100644 --- a/CRM/Utils/Hook.php +++ b/CRM/Utils/Hook.php @@ -160,7 +160,7 @@ abstract class CRM_Utils_Hook { // Instead of not calling any hooks we only call those we know to be frequently important - if a particular extension wanted // to avoid this they could do an early return on CRM_Core_Config::singleton()->isUpgradeMode // Futther discussion is happening at https://lab.civicrm.org/dev/core/issues/1460 - $upgradeFriendlyHooks = ['civicrm_alterSettingsFolders', 'civicrm_alterSettingsMetaData', 'civicrm_triggerInfo', 'civicrm_alterLogTables', 'civicrm_container']; + $upgradeFriendlyHooks = ['civicrm_alterSettingsFolders', 'civicrm_alterSettingsMetaData', 'civicrm_triggerInfo', 'civicrm_alterLogTables', 'civicrm_container', 'civicrm_permission']; if (CRM_Core_Config::singleton()->isUpgradeMode() && !in_array($fnSuffix, $upgradeFriendlyHooks)) { return; } -- 2.25.1