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:
authorThomas Steur <thomas.steur@googlemail.com>2014-07-03 01:12:24 +0400
committerThomas Steur <thomas.steur@googlemail.com>2014-07-03 01:12:24 +0400
commitb5ac22280e0538b4753c8331ff4dae11c055ed0e (patch)
tree9200c4670e2e771391d39a5b54b8af684b6ede84 /core/WidgetsList.php
parentb8373e7e7e672c9f46212680643b0346d78b6e5b (diff)
fix last remaining wigetslist test
Diffstat (limited to 'core/WidgetsList.php')
-rw-r--r--core/WidgetsList.php13
1 files changed, 12 insertions, 1 deletions
diff --git a/core/WidgetsList.php b/core/WidgetsList.php
index b18807b74d..9ac66de81b 100644
--- a/core/WidgetsList.php
+++ b/core/WidgetsList.php
@@ -38,6 +38,13 @@ class WidgetsList extends Singleton
static protected $hookCalled = false;
/**
+ * In get() we won't use a cached result in case this is true. Instead we will sort the widgets again and cache
+ * a new result. To make tests work...
+ * @var bool
+ */
+ static private $listCacheToBeInvalidated = false;
+
+ /**
* Returns all available widgets.
*
* @return array Array Mapping widget categories with an array of widget information, eg,
@@ -57,7 +64,7 @@ class WidgetsList extends Singleton
static public function get()
{
$cache = self::getCacheForCompleteList();
- if ($cache->has()) {
+ if (!self::$listCacheToBeInvalidated && $cache->has()) {
return $cache->get();
}
@@ -77,6 +84,7 @@ class WidgetsList extends Singleton
}
$cache->set($widgets);
+ self::$listCacheToBeInvalidated = false;
return $widgets;
}
@@ -178,6 +186,7 @@ class WidgetsList extends Singleton
self::$widgets[$widgetCategory] = array();
}
+ self::$listCacheToBeInvalidated = true;
self::$widgets[$widgetCategory][] = array(
'name' => $widgetName,
'uniqueId' => $widgetUniqueId,
@@ -203,11 +212,13 @@ class WidgetsList extends Singleton
if (empty($widgetName)) {
unset(self::$widgets[$widgetCategory]);
+ self::$listCacheToBeInvalidated = true;
return;
}
foreach (self::$widgets[$widgetCategory] as $id => $widget) {
if ($widget['name'] == $widgetName || $widget['name'] == Piwik::translate($widgetName)) {
unset(self::$widgets[$widgetCategory][$id]);
+ self::$listCacheToBeInvalidated = true;
return;
}
}