| <?php |
|
|
| |
| |
| |
| |
| |
| |
|
|
| namespace Piwik\Plugins\CoreAdminHome\Tasks; |
|
|
| use Piwik\Concurrency\DistributedList; |
| use Piwik\Date; |
|
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| class ArchivesToPurgeDistributedList extends DistributedList |
| { |
| public const OPTION_INVALIDATED_DATES_SITES_TO_PURGE = 'InvalidatedOldReports_DatesWebsiteIds'; |
|
|
| public function __construct() |
| { |
| parent::__construct(self::OPTION_INVALIDATED_DATES_SITES_TO_PURGE); |
| } |
|
|
| |
| |
| |
| public function setAll($yearMonths) |
| { |
| $yearMonths = array_unique($yearMonths, SORT_REGULAR); |
| parent::setAll($yearMonths); |
| } |
|
|
| protected function getListOptionValue() |
| { |
| $result = parent::getListOptionValue(); |
| $this->convertOldDistributedList($result); |
| return $result; |
| } |
|
|
| public function getAllAsDates() |
| { |
| $dates = array(); |
| foreach ($this->getAll() as $yearMonth) { |
| try { |
| $date = Date::factory(str_replace('_', '-', $yearMonth) . '-01'); |
| } catch (\Exception $ex) { |
| continue; |
| } |
|
|
| $dates[] = $date; |
| } |
| return $dates; |
| } |
|
|
| public function removeDate(Date $date) |
| { |
| $yearMonth = $date->toString('Y_m'); |
| $this->remove($yearMonth); |
| } |
|
|
| |
| |
| |
| |
| |
| private function convertOldDistributedList(&$yearMonths) |
| { |
| foreach ($yearMonths as $key => $value) { |
| if (preg_match("/^[0-9]{4}_[0-9]{2}$/", $key)) { |
| unset($yearMonths[$key]); |
|
|
| $yearMonths[] = $key; |
| } |
| } |
| } |
| } |
|
|