Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/matomo-org/matomo.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--core/Archive.php147
-rw-r--r--core/ArchiveProcessing.php41
-rw-r--r--core/ArchiveProcessing/Day.php2
-rw-r--r--core/ArchiveProcessing/Period.php2
-rw-r--r--core/DataAccess/ArchiveQuery.php18
5 files changed, 105 insertions, 105 deletions
diff --git a/core/Archive.php b/core/Archive.php
index 42690fb379..d711624cde 100644
--- a/core/Archive.php
+++ b/core/Archive.php
@@ -572,51 +572,21 @@ class Piwik_Archive
}
/**
- * Returns the report names for a list of metric/record names.
- *
- * @see getRequestedReport
+ * Returns the list of plugins that archive the given reports.
*
* @param array $archiveNames
+ * @return array
*/
- public function getRequestedReports($archiveNames)
+ public function getRequestedPlugins($archiveNames)
{
$result = array();
foreach ($archiveNames as $name) {
- $result[] = self::getRequestedReport($name);
+ $result[] = self::getPluginForReport($name);
}
return array_unique($result);
}
/**
- * Returns the report name for a metric/record name.
- *
- * A report name has the following format: {$pluginName}_{$reportId}, eg. VisitFrequency_Metrics.
- * The report ID is not used anywhere in Piwik.
- */
- public static function getRequestedReport($archiveName)
- {
- // Core metrics are always processed in Core, for the requested date/period/segment
- if (in_array($archiveName, Piwik_ArchiveProcessing::getCoreMetrics())
- || $archiveName == 'max_actions'
- ) {
- return 'VisitsSummary_CoreMetrics';
- }
- // VisitFrequency metrics don't follow the same naming convention (HACK)
- else if(strpos($archiveName, '_returning') > 0
- // ignore Goal_visitor_returning_1_1_nb_conversions
- && strpos($archiveName, 'Goal_') === false
- ) {
- return 'VisitFrequency_Metrics';
- }
- // Goal_* metrics are processed by the Goals plugin (HACK)
- else if(strpos($archiveName, 'Goal_') === 0) {
- return 'Goals_Metrics';
- } else {
- return $archiveName;
- }
- }
-
- /**
* Helper - Loads a DataTable from the Archive.
* Optionally loads the table recursively,
* or optionally fetches a given subtable with $idSubtable
@@ -703,19 +673,18 @@ class Piwik_Archive
*/
private function getArchiveIds($archiveNames)
{
- $requestedReports = $this->getRequestedReports($archiveNames);
+ $plugins = $this->getRequestedPlugins($archiveNames);
// figure out which archives haven't been processed (if an archive has been processed,
// then we have the archive IDs in $this->idarchives)
$doneFlags = array();
$archiveGroups = array();
- foreach ($requestedReports as $report) {
- $doneFlag = Piwik_ArchiveProcessing::getDoneStringFlagFor(
- $this->segment, $this->getPeriodLabel(), $report);
+ foreach ($plugins as $plugin) {
+ $doneFlag = $this->getDoneStringForPlugin($plugin);
$doneFlags[$doneFlag] = true;
if (!isset($this->idarchives[$doneFlag])) {
- $archiveGroups[] = $this->getArchiveGroupOfReport($report);
+ $archiveGroups[] = $this->getArchiveGroupOfPlugin($plugin);
}
}
@@ -724,9 +693,9 @@ class Piwik_Archive
// cache id archives for plugins we haven't processed yet
if (!empty($archiveGroups)) {
if (!$this->isArchivingDisabled()) {
- $this->cacheArchiveIdsAfterLaunching($archiveGroups, $requestedReports);
+ $this->cacheArchiveIdsAfterLaunching($archiveGroups, $plugins);
} else {
- $this->cacheArchiveIdsWithoutLaunching($requestedReports);
+ $this->cacheArchiveIdsWithoutLaunching($plugins);
}
}
@@ -753,9 +722,9 @@ class Piwik_Archive
* metrics/reports have not been calculated/archived already.
*
* @param array $archiveGroups @see getArchiveGroupOfReport
- * @param array $requestedReports @see getRequestedReport
+ * @param array $plugins List of plugin names to archive.
*/
- private function cacheArchiveIdsAfterLaunching($archiveGroups, $requestedReports)
+ private function cacheArchiveIdsAfterLaunching($archiveGroups, $plugins)
{
$today = Piwik_Date::today();
@@ -793,19 +762,17 @@ class Piwik_Archive
$processing->isThereSomeVisits = null;
- // process for each requested report as well
- foreach ($archiveGroups as $pluginOrAll) {
- if ($pluginOrAll == 'all') {
- $pluginOrAll = $this->getPluginForReport(reset($requestedReports));
+ // process for each plugin as well
+ foreach ($archiveGroups as $plugin) {
+ if ($plugin == 'all') {
+ $plugin = reset($plugins);
}
- $report = $pluginOrAll.'_reportsAndMetrics';
- $doneFlag = Piwik_ArchiveProcessing::getDoneStringFlagFor(
- $this->segment, $period->getLabel(), $report);
+ $doneFlag = $this->getDoneStringForPlugin($plugin);
$this->initializeArchiveIdCache($doneFlag);
$processing->init();
- $processing->setRequestedReport($report);
+ $processing->setRequestedPlugin($plugin);
// launch archiving if the requested data hasn't been archived
$idArchive = $processing->loadArchive();
@@ -829,21 +796,19 @@ class Piwik_Archive
* This function will not launch the archiving process (and is thus much, much faster
* than cacheArchiveIdsAfterLaunching).
*
- * @param array $requestedReports @see getRequestedReport
+ * @param array $plugins List of plugin names from which data is being requested.
*/
- private function cacheArchiveIdsWithoutLaunching($requestedReports)
+ private function cacheArchiveIdsWithoutLaunching($plugins)
{
- $periodType = $this->getPeriodLabel();
-
$idarchivesByReport = $this->dataAccess->getArchiveIds(
- $this->siteIds, $this->periods, $this->segment, $requestedReports);
+ $this->siteIds, $this->periods, $this->segment, $plugins);
// initialize archive ID cache for each report
- foreach ($requestedReports as $report) {
- $doneFlag = Piwik_ArchiveProcessing::getDoneStringFlagFor($this->segment, $periodType, $report);
+ foreach ($plugins as $plugin) {
+ $doneFlag = $this->getDoneStringForPlugin($plugin);
$this->initializeArchiveIdCache($doneFlag);
}
-
+
foreach ($idarchivesByReport as $doneFlag => $idarchivesByDate) {
foreach ($idarchivesByDate as $dateRange => $idarchives) {
foreach ($idarchives as $idarchive) {
@@ -854,6 +819,19 @@ class Piwik_Archive
}
/**
+ * Returns the done string flag for a plugin using this instance's segment & periods.
+ *
+ * @see Piwik_ArchiveProcessing::getDoneStringFlagFor
+ *
+ * @param string $plugin
+ * @return string
+ */
+ private function getDoneStringForPlugin($plugin)
+ {
+ return Piwik_ArchiveProcessing::getDoneStringFlagFor($this->segment, $this->getPeriodLabel(), $plugin);
+ }
+
+ /**
* Returns an ArchiveProcessing instance that should be used for a specific
* period.
*
@@ -957,28 +935,61 @@ class Piwik_Archive
}
/**
- * Returns the archiving group identifier of a report.
+ * Returns the archiving group identifier given a plugin.
*
- * More than one plugin can be called at once. In such a case we don't want to
- * launch archiving three times for three plugins if doing it once is enough,
- * so getArchiveIds makes sure to get the archive group of all reports.
+ * More than one plugin can be called at once when archiving. In such a case
+ * we don't want to launch archiving three times for three plugins if doing
+ * it once is enough, so getArchiveIds makes sure to get the archive group of
+ * all reports.
*
* If the period isn't a range, then all plugins' archiving code is executed.
* If the period is a range, then archiving code is executed individually for
* each plugin.
*/
- private function getArchiveGroupOfReport($report)
+ private function getArchiveGroupOfPlugin($plugin)
{
if ($this->getPeriodLabel() != 'range') {
return 'all';
}
- return $this->getPluginForReport($report);
+ return $plugin;
}
- private function getPluginForReport($report)
+ /**
+ * Returns the name of the plugin that archives a given report.
+ *
+ * @param string $report Archive data name, ie, 'nb_visits', 'UserSettings_...', etc.
+ * @return string
+ */
+ public static function getPluginForReport($report)
{
- $parts = explode('_', $report);
- return $parts[0];
+ // Core metrics are always processed in Core, for the requested date/period/segment
+ if (in_array($report, Piwik_ArchiveProcessing::getCoreMetrics())
+ || $report == 'max_actions'
+ ) {
+ $report = 'VisitsSummary_CoreMetrics';
+ }
+ // VisitFrequency metrics don't follow the same naming convention (HACK)
+ else if(strpos($report, '_returning') > 0
+ // ignore Goal_visitor_returning_1_1_nb_conversions
+ && strpos($report, 'Goal_') === false
+ ) {
+ $report = 'VisitFrequency_Metrics';
+ }
+ // Goal_* metrics are processed by the Goals plugin (HACK)
+ else if(strpos($report, 'Goal_') === 0) {
+ $report = 'Goals_Metrics';
+ }
+
+ $plugin = substr($report, 0, strpos($report, '_'));
+ if (empty($plugin)
+ || !Piwik_PluginsManager::getInstance()->isPluginActivated($plugin)
+ ) {
+ $pluginStr = empty($plugin) ? '' : "($plugin)";
+ throw new Exception("Error: The report '$report' was requested but it is not available "
+ . "at this stage. You may also disable the related plugin $pluginStr "
+ . "to avoid this error.");
+ }
+ return $plugin;
}
}
diff --git a/core/ArchiveProcessing.php b/core/ArchiveProcessing.php
index 31af7e1047..87870f67cf 100644
--- a/core/ArchiveProcessing.php
+++ b/core/ArchiveProcessing.php
@@ -507,7 +507,7 @@ abstract class Piwik_ArchiveProcessing
public function getDoneStringFlag($flagArchiveAsAllPlugins = false)
{
return self::getDoneStringFlagFor(
- $this->getSegment(), $this->period->getLabel(), $this->getRequestedReport(), $flagArchiveAsAllPlugins);
+ $this->getSegment(), $this->period->getLabel(), $this->getRequestedPlugin(), $flagArchiveAsAllPlugins);
}
/**
@@ -516,21 +516,20 @@ abstract class Piwik_ArchiveProcessing
*
* @param Piwik_Segment $segment
* @param string $periodLabel
- * @param string $requestedReport
+ * @param string $plugin
* @param bool $flagArchiveAsAllPlugins
* @return string
*/
- public static function getDoneStringFlagFor($segment, $periodLabel, $requestedReport, $flagArchiveAsAllPlugins = false)
+ public static function getDoneStringFlagFor($segment, $periodLabel, $plugin, $flagArchiveAsAllPlugins = false)
{
$segmentHash = $segment->getHash();
if (!self::shouldProcessReportsAllPluginsFor($segment, $periodLabel)) {
- $pluginProcessed = self::getPluginBeingProcessed($requestedReport);
- if (!Piwik_PluginsManager::getInstance()->isPluginLoaded($pluginProcessed)
+ if (!Piwik_PluginsManager::getInstance()->isPluginLoaded($plugin)
|| $flagArchiveAsAllPlugins
) {
- $pluginProcessed = 'all';
+ $plugin = 'all';
}
- $segmentHash .= '.' . $pluginProcessed;
+ $segmentHash .= '.' . $plugin;
}
return 'done' . $segmentHash;
}
@@ -556,7 +555,7 @@ abstract class Piwik_ArchiveProcessing
$this->idsite,
$temporary,
$this->getSegment()->getString(),
- $this->getRequestedReport(),
+ $this->getRequestedPlugin(),
$this->startDatetimeUTC,
$this->endTimestampUTC
));
@@ -634,26 +633,14 @@ abstract class Piwik_ArchiveProcessing
$this->site = $site;
}
- public function setRequestedReport($requestedReport)
+ public function setRequestedPlugin($plugin)
{
- $this->requestedReport = $requestedReport;
+ $this->requestedPlugin = $plugin;
}
-
- public function getRequestedReport()
- {
- return $this->requestedReport;
- }
-
- public static function getPluginBeingProcessed($requestedReport)
+
+ public function getRequestedPlugin()
{
- $plugin = substr($requestedReport, 0, strpos($requestedReport, '_'));
- if (empty($plugin)
- || !Piwik_PluginsManager::getInstance()->isPluginActivated($plugin)
- ) {
- $pluginStr = empty($plugin) ? '' : "($plugin)";
- throw new Exception("Error: The report '$requestedReport' was requested but it is not available at this stage. You may also disable the related plugin $pluginStr to avoid this error.");
- }
- return $plugin;
+ return $this->requestedPlugin;
}
/**
@@ -931,7 +918,7 @@ abstract class Piwik_ArchiveProcessing
return false;
}
- if ($this->getPluginBeingProcessed($this->getRequestedReport()) == 'VisitsSummary') {
+ if ($this->getRequestedPlugin() == 'VisitsSummary') {
$this->isThereSomeVisits = false;
}
@@ -1045,7 +1032,7 @@ abstract class Piwik_ArchiveProcessing
// If any other segment, only process if the requested report belong to this plugin
// or process all plugins if the requested report plugin couldn't be guessed
- $pluginBeingProcessed = self::getPluginBeingProcessed($this->getRequestedReport());
+ $pluginBeingProcessed = $this->getRequestedPlugin();
return $pluginBeingProcessed == $pluginName
|| !Piwik_PluginsManager::getInstance()->isPluginLoaded($pluginBeingProcessed);
}
diff --git a/core/ArchiveProcessing/Day.php b/core/ArchiveProcessing/Day.php
index 96a630a93a..17eedf5471 100644
--- a/core/ArchiveProcessing/Day.php
+++ b/core/ArchiveProcessing/Day.php
@@ -71,7 +71,7 @@ class Piwik_ArchiveProcessing_Day extends Piwik_ArchiveProcessing
// If no specified Segment
// Or if a segment is passed and we specifically process VisitsSummary
// Then we check the logs. This is to ensure that this query is ran only once for this day/site/segment (rather than running it for every plugin)
- $reportType = self::getPluginBeingProcessed($this->getRequestedReport());
+ $reportType = $this->getRequestedPlugin();
if ($this->shouldProcessReportsAllPlugins($this->getSegment(), $this->period)
|| ($reportType == 'VisitsSummary')
) {
diff --git a/core/ArchiveProcessing/Period.php b/core/ArchiveProcessing/Period.php
index 840f5b5c97..e66458239c 100644
--- a/core/ArchiveProcessing/Period.php
+++ b/core/ArchiveProcessing/Period.php
@@ -335,7 +335,7 @@ class Piwik_ArchiveProcessing_Period extends Piwik_ArchiveProcessing
}
$this->loadSubPeriods();
- if (self::getPluginBeingProcessed($this->getRequestedReport()) == 'VisitsSummary'
+ if ($this->getRequestedPlugin() == 'VisitsSummary'
|| $this->shouldProcessReportsAllPlugins($this->getSegment(), $this->period)
) {
$toSum = self::getCoreMetrics();
diff --git a/core/DataAccess/ArchiveQuery.php b/core/DataAccess/ArchiveQuery.php
index ca3fbbd0e5..ef108db29e 100644
--- a/core/DataAccess/ArchiveQuery.php
+++ b/core/DataAccess/ArchiveQuery.php
@@ -20,7 +20,7 @@ class Piwik_DataAccess_ArchiveQuery
* @param array $siteIds
* @param array $periods
* @param Piwik_Segment|null $segment
- * @param array $requestedReports
+ * @param array $plugins List of plugin names for which data is being requested.
* @return array Archive IDs are grouped by archive name and period range, ie,
* array(
* 'VisitsSummary.done' => array(
@@ -28,7 +28,7 @@ class Piwik_DataAccess_ArchiveQuery
* )
* )
*/
- public function getArchiveIds($siteIds, $periods, $segment, $requestedReports)
+ public function getArchiveIds($siteIds, $periods, $segment, $plugins)
{
$periodType = reset($periods)->getLabel();
@@ -36,7 +36,7 @@ class Piwik_DataAccess_ArchiveQuery
FROM %s
WHERE period = ?
AND %s
- AND ".$this->getNameCondition($requestedReports, $segment, $periodType)."
+ AND ".$this->getNameCondition($plugins, $segment, $periodType)."
AND idsite IN (".implode(',', $siteIds).")
GROUP BY idsite, date1, date2";
@@ -132,17 +132,19 @@ class Piwik_DataAccess_ArchiveQuery
* Returns the SQL condition used to find successfully completed archives that
* this instance is querying for.
*
- * @param array $requestedReports @see getRequestedReport
+ * @param array $plugins @see getArchiveData
+ * @param Piwik_Segment $segment
+ * @param string $periodType
* @return string
*/
- private function getNameCondition($requestedReports, $segment, $periodType)
+ private function getNameCondition($plugins, $segment, $periodType)
{
// the flags used to tell how the archiving process for a specific archive was completed,
// if it was completed
$doneFlags = array();
- foreach ($requestedReports as $report) {
- $done = Piwik_ArchiveProcessing::getDoneStringFlagFor($segment, $periodType, $report);
- $donePlugins = Piwik_ArchiveProcessing::getDoneStringFlagFor($segment, $periodType, $report, true);
+ foreach ($plugins as $plugin) {
+ $done = Piwik_ArchiveProcessing::getDoneStringFlagFor($segment, $periodType, $plugin);
+ $donePlugins = Piwik_ArchiveProcessing::getDoneStringFlagFor($segment, $periodType, $plugin, true);
$doneFlags[$done] = $done;
$doneFlags[$donePlugins] = $donePlugins;