public function tearDown() { if (!SharedSiteIds::isSupported()) { return; } $siteIdsToCleanup = new SharedSiteIds(array()); $siteIdsToCleanup->setSiteIdsToArchive(array()); parent::tearDown(); }
private function createSitesToArchiveQueue($websitesIds) { // use synchronous, single process queue if --force-idsites is used or sharing site IDs isn't supported if (!SharedSiteIds::isSupported() || !empty($this->shouldArchiveSpecifiedSites)) { return new FixedSiteIds($websitesIds); } // use separate shared queue if --force-all-websites is used if (!empty($this->shouldArchiveAllSites)) { return new SharedSiteIds($websitesIds, SharedSiteIds::OPTION_ALL_WEBSITES); } return new SharedSiteIds($websitesIds); }
public function test_isSupported() { $this->assertTrue(SharedSiteIds::isSupported()); }
public function init() { // Note: the order of methods call matters here. $this->initCore(); $this->initTokenAuth(); $this->initCheckCli(); $this->initStateFromParameters(); Piwik::setUserHasSuperUserAccess(true); $this->logInitInfo(); $this->checkPiwikUrlIsValid(); $this->logArchiveTimeoutInfo(); // record archiving start time Option::set(self::OPTION_ARCHIVING_STARTED_TS, time()); $this->segments = $this->initSegmentsToArchive(); $this->allWebsites = APISitesManager::getInstance()->getAllSitesId(); if (!empty($this->shouldArchiveOnlySpecificPeriods)) { $this->log("- Will process the following periods: " . implode(", ", $this->shouldArchiveOnlySpecificPeriods) . " (--force-periods)"); } $websitesIds = $this->initWebsiteIds(); $this->filterWebsiteIds($websitesIds); if (!empty($this->shouldArchiveSpecifiedSites) || !empty($this->shouldArchiveAllSites) || !SharedSiteIds::isSupported()) { $this->websites = new FixedSiteIds($websitesIds); } else { $this->websites = new SharedSiteIds($websitesIds); if ($this->websites->getInitialSiteIds() != $websitesIds) { $this->log('Will ignore websites and help finish a previous started queue instead. IDs: ' . implode(', ', $this->websites->getInitialSiteIds())); } } if ($this->shouldStartProfiler) { \Piwik\Profiler::setupProfilerXHProf($mainRun = true); $this->log("XHProf profiling is enabled."); } /** * This event is triggered after a CronArchive instance is initialized. * * @param array $websiteIds The list of website IDs this CronArchive instance is processing. * This will be the entire list of IDs regardless of whether some have * already been processed. */ Piwik::postEvent('CronArchive.init.finish', array($this->websites->getInitialSiteIds())); }