Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/matomo-org/matomo.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStefan Giehl <stefan@matomo.org>2020-02-25 23:41:55 +0300
committerGitHub <noreply@github.com>2020-02-25 23:41:55 +0300
commitbaa4c285d80073365d5a12569df238fba5b9a1ab (patch)
treefbb564c3366a89174f588600913b3df7c11ac335 /core/Menu/MenuAbstract.php
parent4fdbab2515ade1958f9796fc4da62de47d99ea78 (diff)
use transient cache for caching menus instead static array (#15585)
Diffstat (limited to 'core/Menu/MenuAbstract.php')
-rw-r--r--core/Menu/MenuAbstract.php27
1 files changed, 11 insertions, 16 deletions
diff --git a/core/Menu/MenuAbstract.php b/core/Menu/MenuAbstract.php
index f5f8062d97..46d5b27987 100644
--- a/core/Menu/MenuAbstract.php
+++ b/core/Menu/MenuAbstract.php
@@ -8,6 +8,7 @@
*/
namespace Piwik\Menu;
+use Piwik\Cache;
use Piwik\Container\StaticContainer;
use Piwik\Plugins\SitesManager\API;
use Piwik\Singleton;
@@ -32,13 +33,12 @@ abstract class MenuAbstract extends Singleton
protected $renames = array();
protected $orderingApplied = false;
protected $menuIcons = array();
- protected static $menus = array();
/**
* Builds the menu, applies edits, renames
* and orders the entries.
*
- * @return Array
+ * @return array
*/
public function getMenu()
{
@@ -68,28 +68,23 @@ abstract class MenuAbstract extends Singleton
*/
protected function getAllMenus()
{
- if (!empty(self::$menus)) {
- return self::$menus;
+ $cacheId = 'Menus.all';
+ $cache = Cache::getTransientCache();
+
+ if ($cache->contains($cacheId)) {
+ return $cache->fetch($cacheId);
}
$components = PluginManager::getInstance()->findComponents('Menu', 'Piwik\\Plugin\\Menu');
- self::$menus = array();
+ $menus = array();
foreach ($components as $component) {
- self::$menus[] = StaticContainer::get($component);
+ $menus[] = StaticContainer::get($component);
}
- return self::$menus;
- }
+ $cache->save($cacheId, $menus);
- /**
- * To use only for tests.
- *
- * @deprecated The whole $menus cache should be replaced by a real transient cache
- */
- public static function clearMenus()
- {
- self::$menus = array();
+ return $menus;
}
/**