/** * Instantiates the Archiver class in each plugin that defines it, * and triggers Aggregation processing on these plugins. */ public function callAggregateAllPlugins($visits, $visitsConverted) { Log::debug("PluginsArchiver::%s: Initializing archiving process for all plugins [visits = %s, visits converted = %s]", __FUNCTION__, $visits, $visitsConverted); $this->archiveProcessor->setNumberOfVisits($visits, $visitsConverted); $archivers = $this->getPluginArchivers(); foreach ($archivers as $pluginName => $archiverClass) { // We clean up below all tables created during this function call (and recursive calls) $latestUsedTableId = Manager::getInstance()->getMostRecentTableId(); /** @var Archiver $archiver */ $archiver = new $archiverClass($this->archiveProcessor); if (!$archiver->isEnabled()) { Log::debug("PluginsArchiver::%s: Skipping archiving for plugin '%s'.", __FUNCTION__, $pluginName); continue; } if ($this->shouldProcessReportsForPlugin($pluginName)) { $this->logAggregator->setQueryOriginHint($pluginName); try { $timer = new Timer(); if ($this->isSingleSiteDayArchive) { Log::debug("PluginsArchiver::%s: Archiving day reports for plugin '%s'.", __FUNCTION__, $pluginName); $archiver->aggregateDayReport(); } else { Log::debug("PluginsArchiver::%s: Archiving period reports for plugin '%s'.", __FUNCTION__, $pluginName); $archiver->aggregateMultipleReports(); } $this->logAggregator->setQueryOriginHint(''); Log::debug("PluginsArchiver::%s: %s while archiving %s reports for plugin '%s'.", __FUNCTION__, $timer->getMemoryLeak(), $this->params->getPeriod()->getLabel(), $pluginName); } catch (Exception $e) { $className = get_class($e); $exception = new $className($e->getMessage() . " - caused by plugin {$pluginName}", $e->getCode(), $e); throw $exception; } } else { Log::debug("PluginsArchiver::%s: Not archiving reports for plugin '%s'.", __FUNCTION__, $pluginName); } Manager::getInstance()->deleteAll($latestUsedTableId); unset($archiver); } }