mirror of
https://github.com/espocrm/espocrm.git
synced 2026-06-28 06:56:05 +00:00
disable hooks while rebuild
This commit is contained in:
@@ -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();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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)) {
|
||||
|
||||
Reference in New Issue
Block a user