diff options
author | mattab <matthieu.aubry@gmail.com> | 2013-11-21 06:19:58 +0400 |
---|---|---|
committer | mattab <matthieu.aubry@gmail.com> | 2013-11-21 06:19:58 +0400 |
commit | c6945b8bceb9eb56e2d72ff98f7f9a07b7bc0ebe (patch) | |
tree | 0d6a2c64a95ae49b8bb8afd61972bb6b7fd4c335 | |
parent | e247407565d79c351815d91db765cf690e8b043e (diff) |
Add a new hook 'CronArchive.filterWebsiteIds'
* When the cron to run archive.php is executed, it fetches the list of website IDs to process.
* Use this hook to add, remove, or change the order of websites IDs to pre-archive.
-rw-r--r-- | core/CronArchive.php | 23 |
1 files changed, 16 insertions, 7 deletions
diff --git a/core/CronArchive.php b/core/CronArchive.php index be9d1b63a0..658ecf9339 100644 --- a/core/CronArchive.php +++ b/core/CronArchive.php @@ -145,7 +145,9 @@ Notes: $this->segments = $this->initSegmentsToArchive(); $this->allWebsites = APISitesManager::getInstance()->getAllSitesId(); - $this->websites = $this->initWebsitesToProcess(); + $websitesIds = $this->initWebsiteIds(); + $this->filterWebsiteIds($websitesIds); + $this->websites = $websitesIds; if($this->shouldStartProfiler) { \Piwik\Profiler::setupProfilerXHProf($mainRun = true); $this->log("XHProf profiling is enabled."); @@ -772,14 +774,24 @@ Notes: } } + private function filterWebsiteIds(&$websiteIds) + { + /** + * When the cron to run archive.php is executed, it fetches the list of website IDs to process. + * Use this hook to add, remove, or change the order of websites IDs to pre-archive. + */ + Piwik::postEvent('CronArchive.filterWebsiteIds', array(&$websiteIds)); + } + /** * Returns the list of sites to loop over and archive. * @return array */ - private function initWebsitesToProcess() + private function initWebsiteIds() { if(count($this->shouldArchiveSpecifiedSites) > 0) { $this->log("- Will process " . count($this->shouldArchiveSpecifiedSites) . " websites (--force-idsites)"); + return $this->shouldArchiveSpecifiedSites; } if ($this->shouldArchiveAllSites) { @@ -791,11 +803,8 @@ Notes: $this->addWebsiteIdsWithVisitsSinceLastRun(), $this->addWebsiteIdsToReprocess() ); - $websiteIds = array_merge($websiteIds, - $this->addWebsiteIdsInTimezoneWithNewDay($websiteIds) - ); - - return array_unique( $websiteIds ); + $websiteIds = array_merge($websiteIds, $this->addWebsiteIdsInTimezoneWithNewDay($websiteIds)); + return array_unique($websiteIds); } private function initTokenAuth() |