diff --git a/application/Espo/Core/DataManager.php b/application/Espo/Core/DataManager.php index 3a4cdce944..90d8e2f31e 100644 --- a/application/Espo/Core/DataManager.php +++ b/application/Espo/Core/DataManager.php @@ -38,7 +38,6 @@ class DataManager private $cachePath = 'data/cache'; - public function __construct(Container $container) { $this->container = $container; @@ -58,6 +57,8 @@ class DataManager { $result = $this->clearCache(); + $this->disableHooks(); + $this->populateConfigParameters(); $result &= $this->rebuildMetadata(); @@ -66,6 +67,8 @@ class DataManager $this->rebuildScheduledJobs(); + $this->enableHooks(); + return $result; } @@ -228,4 +231,14 @@ class DataManager $config->save(); } + + protected function disableHooks() + { + $this->getContainer()->get('hookManager')->disable(); + } + + protected function enableHooks() + { + $this->getContainer()->get('hookManager')->enable(); + } } diff --git a/application/Espo/Core/HookManager.php b/application/Espo/Core/HookManager.php index 241fe3a06a..af434351e9 100644 --- a/application/Espo/Core/HookManager.php +++ b/application/Espo/Core/HookManager.php @@ -49,6 +49,8 @@ class HookManager private $data; + protected $isDisabled; + private $hookListHash = []; private $hooks; @@ -81,6 +83,10 @@ class HookManager public function process(string $scope, string $hookName, $injection = null, array $options = [], array $hookData = []) { + if ($this->isDisabled) { + return; + } + if (!isset($this->data)) { $this->loadHooks(); } @@ -99,6 +105,22 @@ class HookManager } } + /** + * Disable hook processing. + */ + public function disable() + { + $this->isDisabled = true; + } + + /** + * Enable hook processing. + */ + public function enable() + { + $this->isDisabled = false; + } + protected function loadHooks() { if ($this->config->get('useCache') && file_exists($this->cacheFile)) {