public function test_generateQuery_WithQueryHint_ShouldAddQueryHintAsComment() { $this->logAggregator->setQueryOriginHint('MyPluginName'); $query = $this->logAggregator->generateQuery('test, test2', 'log_visit', '1=1', false, '5'); $expected = array('sql' => 'SELECT /* MyPluginName */ test, test2 FROM log_visit AS log_visit WHERE 1=1 ORDER BY 5', 'bind' => array(0 => '2012-01-01 00:00:00', 1 => '2012-01-31 23:59:59', 2 => 1)); $this->assertSame($expected, $query); }
/** * 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); $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); } else { Log::debug("PluginsArchiver::%s: Not archiving reports for plugin '%s'.", __FUNCTION__, $pluginName); } Manager::getInstance()->deleteAll($latestUsedTableId); unset($archiver); } }