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; // invalid year month in distributed list } $dates[] = $date; } return $dates; } public function removeDate(Date $date) { $yearMonth = $date->toString('Y_m'); $this->remove($yearMonth); } /** * Before 2.12.0 Piwik stored this list as an array mapping year months to arrays of site IDs. If this is * found in the DB, we convert the array to an array of year months to avoid errors and to make sure * the correct tables are still purged. */ private function convertOldDistributedList(&$yearMonths) { foreach ($yearMonths as $key => $value) { if (preg_match("/^[0-9]{4}_[0-9]{2}$/", $key)) { unset($yearMonths[$key]); $yearMonths[] = $key; } } } }