From 25e7a79defefbe299746c7ddd30509625c17296f Mon Sep 17 00:00:00 2001 From: mattab Date: Fri, 8 Nov 2013 13:26:52 +1300 Subject: Refs #4278 breaking down functions --- core/Archive.php | 57 +++++++++++++++++++++++++++++++++----------------------- 1 file changed, 34 insertions(+), 23 deletions(-) (limited to 'core/Archive.php') diff --git a/core/Archive.php b/core/Archive.php index 084abb17dd..e0232f698f 100644 --- a/core/Archive.php +++ b/core/Archive.php @@ -537,7 +537,12 @@ class Archive $doneFlags[$doneFlag] = true; if (!isset($this->idarchives[$doneFlag])) { - $archiveGroups[] = $this->getArchiveGroupOfPlugin($plugin); + $archiveGroup = $this->getArchiveGroupOfPlugin($plugin); + + if($archiveGroup == self::ARCHIVE_ALL_PLUGINS_FLAG) { + $archiveGroup = reset($plugins); + } + $archiveGroups[] = $archiveGroup; } } @@ -546,6 +551,7 @@ class Archive // cache id archives for plugins we haven't processed yet if (!empty($archiveGroups)) { if (!Rules::isArchivingDisabledFor($this->params->getSegment(), $this->getPeriodLabel())) { + $this->cacheArchiveIdsAfterLaunching($archiveGroups, $plugins); } else { $this->cacheArchiveIdsWithoutLaunching($plugins); @@ -583,8 +589,6 @@ class Archive /* @var Period $period */ foreach ($this->params->getPeriods() as $period) { - $periodStr = $period->getRangeString(); - $twoDaysBeforePeriod = $period->getDateStart()->subDay(2); $twoDaysAfterPeriod = $period->getDateEnd()->addDay(2); @@ -607,26 +611,7 @@ class Archive continue; } - $parameters = new ArchiveProcessor\Parameters($site, $period, $this->params->getSegment()); - $processing = new ArchiveProcessor\Loader($parameters); - - // process for each plugin as well - foreach ($archiveGroups as $plugin) { - if ($plugin == self::ARCHIVE_ALL_PLUGINS_FLAG) { - $plugin = reset($plugins); - } - - $doneFlag = $this->getDoneStringForPlugin($plugin); - $this->initializeArchiveIdCache($doneFlag); - - $parameters->setRequestedPlugin($plugin); - $idArchive = $processing->preProcessArchive(); - - $visits = $processing->getNumberOfVisits(); - if ($visits > 0) { - $this->idarchives[$doneFlag][$periodStr][] = $idArchive; - } - } + $this->launchArchiveProcessor($archiveGroups, $site, $period); } } } @@ -789,4 +774,30 @@ class Archive } return $plugin; } + + /**getNumberOfVisits + * @param $archiveGroups + * @param $site + * @param $period + */ + private function launchArchiveProcessor(array $archiveGroups, Site $site, Period $period) + { + $parameters = new ArchiveProcessor\Parameters($site, $period, $this->params->getSegment()); + $processing = new ArchiveProcessor\Loader($parameters); + + $periodString = $period->getRangeString(); + + // process for each plugin as well + foreach ($archiveGroups as $plugin) { + $doneFlag = $this->getDoneStringForPlugin($plugin); + $this->initializeArchiveIdCache($doneFlag); + + $parameters->setRequestedPlugin($plugin); + $idArchive = $processing->prepareArchiveId(); + + if($idArchive) { + $this->idarchives[$doneFlag][$periodString][] = $idArchive; + } + } + } } \ No newline at end of file -- cgit v1.2.3