update Piwik to version 2.16 (fixes #91)
This commit is contained in:
parent
296343bf3b
commit
d885a4baa9
5833 changed files with 418860 additions and 226988 deletions
|
|
@ -1,6 +1,6 @@
|
|||
<?php
|
||||
/**
|
||||
* Piwik - Open source web analytics
|
||||
* Piwik - free/libre analytics platform
|
||||
*
|
||||
* @link http://piwik.org
|
||||
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
|
||||
|
|
@ -9,13 +9,15 @@
|
|||
|
||||
namespace Piwik\ArchiveProcessor;
|
||||
|
||||
use Piwik\Archive;
|
||||
use Piwik\ArchiveProcessor;
|
||||
use Piwik\DataAccess\ArchiveSelector;
|
||||
use Piwik\DataAccess\ArchiveWriter;
|
||||
use Piwik\DataAccess\LogAggregator;
|
||||
use Piwik\DataTable\Manager;
|
||||
use Piwik\Metrics;
|
||||
use Piwik\Plugin\Archiver;
|
||||
use Piwik\Log;
|
||||
use Piwik\Timer;
|
||||
use Exception;
|
||||
|
||||
/**
|
||||
* This class creates the Archiver objects found in plugins and will trigger aggregation,
|
||||
|
|
@ -34,9 +36,16 @@ class PluginsArchiver
|
|||
protected $params;
|
||||
|
||||
/**
|
||||
* @var LogAggregator
|
||||
*/
|
||||
private $logAggregator;
|
||||
|
||||
/**
|
||||
* Public only for tests. Won't be necessary after DI changes are complete.
|
||||
*
|
||||
* @var Archiver[] $archivers
|
||||
*/
|
||||
private static $archivers = array();
|
||||
public static $archivers = array();
|
||||
|
||||
public function __construct(Parameters $params, $isTemporaryArchive)
|
||||
{
|
||||
|
|
@ -45,7 +54,9 @@ class PluginsArchiver
|
|||
$this->archiveWriter = new ArchiveWriter($this->params, $isTemporaryArchive);
|
||||
$this->archiveWriter->initNewArchive();
|
||||
|
||||
$this->archiveProcessor = new ArchiveProcessor($this->params, $this->archiveWriter);
|
||||
$this->logAggregator = new LogAggregator($params);
|
||||
|
||||
$this->archiveProcessor = new ArchiveProcessor($this->params, $this->archiveWriter, $this->logAggregator);
|
||||
|
||||
$this->isSingleSiteDayArchive = $this->params->isSingleSiteDayArchive();
|
||||
}
|
||||
|
|
@ -57,7 +68,9 @@ class PluginsArchiver
|
|||
*/
|
||||
public function callAggregateCoreMetrics()
|
||||
{
|
||||
if($this->isSingleSiteDayArchive) {
|
||||
$this->logAggregator->setQueryOriginHint('Core');
|
||||
|
||||
if ($this->isSingleSiteDayArchive) {
|
||||
$metrics = $this->aggregateDayVisitsMetrics();
|
||||
} else {
|
||||
$metrics = $this->aggregateMultipleVisitsMetrics();
|
||||
|
|
@ -81,27 +94,57 @@ class PluginsArchiver
|
|||
*/
|
||||
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) {
|
||||
|
||||
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()) {
|
||||
if (!$archiver->isEnabled()) {
|
||||
Log::debug("PluginsArchiver::%s: Skipping archiving for plugin '%s'.", __FUNCTION__, $pluginName);
|
||||
continue;
|
||||
}
|
||||
if($this->shouldProcessReportsForPlugin($pluginName)) {
|
||||
if($this->isSingleSiteDayArchive) {
|
||||
$archiver->aggregateDayReport();
|
||||
} else {
|
||||
$archiver->aggregateMultipleReports();
|
||||
|
||||
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);
|
||||
|
|
@ -111,7 +154,7 @@ class PluginsArchiver
|
|||
|
||||
public function finalizeArchive()
|
||||
{
|
||||
$this->params->logStatusDebug( $this->archiveWriter->isArchiveTemporary );
|
||||
$this->params->logStatusDebug($this->archiveWriter->isArchiveTemporary);
|
||||
$this->archiveWriter->finalizeArchive();
|
||||
return $this->archiveWriter->getIdArchive();
|
||||
}
|
||||
|
|
@ -193,5 +236,4 @@ class PluginsArchiver
|
|||
$metrics = $this->archiveProcessor->aggregateNumericMetrics($toSum);
|
||||
return $metrics;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue