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:
authordiosmosis <benaka@piwik.pro>2015-03-31 04:34:10 +0300
committerdiosmosis <benaka@piwik.pro>2015-03-31 04:34:10 +0300
commitb3f4f69ec2c0f7ae77461ffcfa57bc9073e290ae (patch)
tree67a4cc8feb08599fc36264a356e18f05e35094cc /core/Concurrency
parent873fb6f70ecb8d08b374353deb1c47ee2b23fadc (diff)
Refs #7560, if old list is found in DB for ArchivesToPurgeDistributedList, convert it to new list w/ only year-date to avoid error.
Diffstat (limited to 'core/Concurrency')
-rw-r--r--core/Concurrency/DistributedList.php46
1 files changed, 37 insertions, 9 deletions
diff --git a/core/Concurrency/DistributedList.php b/core/Concurrency/DistributedList.php
index 6c6ce340c0..723fda6c76 100644
--- a/core/Concurrency/DistributedList.php
+++ b/core/Concurrency/DistributedList.php
@@ -7,7 +7,9 @@
*/
namespace Piwik\Concurrency;
+use Piwik\Container\StaticContainer;
use Piwik\Option;
+use Psr\Log\LoggerInterface;
/**
* Manages a simple distributed list stored in an Option. No locking occurs, so the list
@@ -27,13 +29,19 @@ class DistributedList
private $optionName;
/**
+ * @var LoggerInterface
+ */
+ private $logger;
+
+ /**
* Constructor.
*
* @param string $optionName
*/
- public function __construct($optionName)
+ public function __construct($optionName, LoggerInterface $logger = null)
{
$this->optionName = $optionName;
+ $this->logger = $logger ?: StaticContainer::get('Psr\Log\LoggerInterface');
}
/**
@@ -43,16 +51,21 @@ class DistributedList
*/
public function getAll()
{
- Option::clearCachedOption($this->optionName);
- $array = Option::get($this->optionName);
+ $result = $this->getListOptionValue();
- if ($array
- && ($array = unserialize($array))
- && count($array)
- ) {
- return $array;
+ foreach ($result as $key => $item) {
+ // remove non-array items (unexpected state, though can happen when upgrading from an old Piwik)
+ if (is_array($item)) {
+ $this->logger->info("Found array item in DistributedList option value '{name}': {data}", array(
+ 'name' => $this->optionName,
+ 'data' => var_export($result, true)
+ ));
+
+ unset($result[$key]);
+ }
}
- return array();
+
+ return $result;
}
/**
@@ -139,4 +152,19 @@ class DistributedList
$this->setAll(array_values($allItems));
}
+
+ protected function getListOptionValue()
+ {
+ Option::clearCachedOption($this->optionName);
+ $array = Option::get($this->optionName);
+
+ $result = array();
+ if ($array
+ && ($array = unserialize($array))
+ && count($array)
+ ) {
+ $result = $array;
+ }
+ return $result;
+ }
} \ No newline at end of file