Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added a cache reset after module updates. #2113

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions application/src/Db/Migration/Manager.php
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,8 @@ public function upgrade()
}

$this->clearDoctrineCache();

$this->clearCache();
}

/**
Expand Down Expand Up @@ -205,4 +207,17 @@ protected function clearDoctrineCache()

$cache->deleteAll();
}

protected function clearCache()
{
if (function_exists('opcache_reset')) {
opcache_reset();
}
if (extension_loaded('apcu')) {
apcu_clear_cache();
}
if (function_exists('clearstatcache')) {
clearstatcache(true);
}
}
}
23 changes: 23 additions & 0 deletions application/src/Module/Manager.php
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,8 @@ public function activate(Module $module)
}

$module->setState(self::STATE_ACTIVE);

$this->clearCache();
}

/**
Expand Down Expand Up @@ -202,6 +204,8 @@ public function deactivate(Module $module)
}

$module->setState(self::STATE_NOT_ACTIVE);

$this->clearCache();
}

/**
Expand Down Expand Up @@ -236,6 +240,8 @@ public function install(Module $module)
$this->getEntityManager()->flush();

$module->setState(self::STATE_ACTIVE);

$this->clearCache();
}

/**
Expand Down Expand Up @@ -277,6 +283,8 @@ public function uninstall(Module $module)
}

$module->setState(self::STATE_NOT_INSTALLED);

$this->clearCache();
}

/**
Expand Down Expand Up @@ -321,6 +329,8 @@ public function upgrade(Module $module)

$module->setState($module->getDb('is_active')
? self::STATE_ACTIVE : self::STATE_NOT_ACTIVE);

$this->clearCache();
}

/**
Expand Down Expand Up @@ -404,4 +414,17 @@ public function getResourceId()
{
return get_called_class();
}

protected function clearCache()
{
if (function_exists('opcache_reset')) {
opcache_reset();
}
if (extension_loaded('apcu')) {
apcu_clear_cache();
}
if (function_exists('clearstatcache')) {
clearstatcache(true);
}
}
}