Skip to content

Commit

Permalink
dev/core#1489 do not reconcile managed entities whilst in upgrade mod…
Browse files Browse the repository at this point in the history
…e 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
  • Loading branch information
seamuslee001 committed Dec 24, 2019
1 parent d129a1b commit 912511a
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 2 deletions.
7 changes: 6 additions & 1 deletion CRM/Core/ManagedEntities.php
Original file line number Diff line number Diff line change
Expand Up @@ -112,10 +112,15 @@ public function get($moduleName, $name) {
/**
* 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);
}
Expand Down
2 changes: 2 additions & 0 deletions CRM/Upgrade/Form.php
Original file line number Diff line number Diff line change
Expand Up @@ -794,6 +794,8 @@ public static function doFinish() {
// Rebuild all triggers and re-enable logging if needed
$logging = new CRM_Logging_Schema();
$logging->fixSchemaDifferences();

CRM_Core_ManagedEntities::singleton(TRUE)->reconcile(TRUE);
}

/**
Expand Down
2 changes: 1 addition & 1 deletion CRM/Utils/Hook.php
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ public function invoke(
// 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;
}
Expand Down

0 comments on commit 912511a

Please sign in to comment.