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
|
||||
|
|
@ -10,11 +10,10 @@ namespace Piwik\Plugins\Actions;
|
|||
|
||||
use PDOStatement;
|
||||
use Piwik\Config;
|
||||
use Piwik\DataTable\Manager;
|
||||
use Piwik\DataTable\Row;
|
||||
use Piwik\DataTable;
|
||||
use Piwik\DataTable\Row\DataTableSummaryRow;
|
||||
use Piwik\Metrics;
|
||||
use Piwik\DataTable;
|
||||
use Piwik\DataTable\Row;
|
||||
use Piwik\Metrics as PiwikMetrics;
|
||||
use Piwik\Piwik;
|
||||
use Piwik\Tracker\Action;
|
||||
use Piwik\Tracker\PageUrl;
|
||||
|
|
@ -38,7 +37,7 @@ class ArchivingHelper
|
|||
* @param array $actionsTablesByType
|
||||
* @return int
|
||||
*/
|
||||
static public function updateActionsTableWithRowQuery($query, $fieldQueried, & $actionsTablesByType)
|
||||
public static function updateActionsTableWithRowQuery($query, $fieldQueried, & $actionsTablesByType, $metricsConfig)
|
||||
{
|
||||
$rowsProcessed = 0;
|
||||
while ($row = $query->fetch()) {
|
||||
|
|
@ -51,7 +50,11 @@ class ArchivingHelper
|
|||
}
|
||||
|
||||
if ($row['type'] != Action::TYPE_SITE_SEARCH) {
|
||||
unset($row[Metrics::INDEX_SITE_SEARCH_HAS_NO_RESULT]);
|
||||
unset($row[PiwikMetrics::INDEX_SITE_SEARCH_HAS_NO_RESULT]);
|
||||
}
|
||||
|
||||
if (in_array($row['type'], array(Action::TYPE_CONTENT, Action::TYPE_EVENT))) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// This will appear as <url /> in the API, which is actually very important to keep
|
||||
|
|
@ -107,15 +110,15 @@ class ArchivingHelper
|
|||
&& !$actionRow->isSummaryRow()
|
||||
) {
|
||||
if (($existingUrl = $actionRow->getMetadata('url')) !== false) {
|
||||
if (!empty($row[Metrics::INDEX_PAGE_NB_HITS])
|
||||
&& $row[Metrics::INDEX_PAGE_NB_HITS] > $actionRow->maxVisitsSummed
|
||||
if (!empty($row[PiwikMetrics::INDEX_PAGE_NB_HITS])
|
||||
&& $row[PiwikMetrics::INDEX_PAGE_NB_HITS] > $actionRow->maxVisitsSummed
|
||||
) {
|
||||
$actionRow->setMetadata('url', $url);
|
||||
$actionRow->maxVisitsSummed = $row[Metrics::INDEX_PAGE_NB_HITS];
|
||||
$actionRow->maxVisitsSummed = $row[PiwikMetrics::INDEX_PAGE_NB_HITS];
|
||||
}
|
||||
} else {
|
||||
$actionRow->setMetadata('url', $url);
|
||||
$actionRow->maxVisitsSummed = !empty($row[Metrics::INDEX_PAGE_NB_HITS]) ? $row[Metrics::INDEX_PAGE_NB_HITS] : 0;
|
||||
$actionRow->maxVisitsSummed = !empty($row[PiwikMetrics::INDEX_PAGE_NB_HITS]) ? $row[PiwikMetrics::INDEX_PAGE_NB_HITS] : 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -123,17 +126,17 @@ class ArchivingHelper
|
|||
&& $row['type'] != Action::TYPE_PAGE_TITLE
|
||||
) {
|
||||
// only keep performance metrics when they're used (i.e. for URLs and page titles)
|
||||
if (array_key_exists(Metrics::INDEX_PAGE_SUM_TIME_GENERATION, $row)) {
|
||||
unset($row[Metrics::INDEX_PAGE_SUM_TIME_GENERATION]);
|
||||
if (array_key_exists(PiwikMetrics::INDEX_PAGE_SUM_TIME_GENERATION, $row)) {
|
||||
unset($row[PiwikMetrics::INDEX_PAGE_SUM_TIME_GENERATION]);
|
||||
}
|
||||
if (array_key_exists(Metrics::INDEX_PAGE_NB_HITS_WITH_TIME_GENERATION, $row)) {
|
||||
unset($row[Metrics::INDEX_PAGE_NB_HITS_WITH_TIME_GENERATION]);
|
||||
if (array_key_exists(PiwikMetrics::INDEX_PAGE_NB_HITS_WITH_TIME_GENERATION, $row)) {
|
||||
unset($row[PiwikMetrics::INDEX_PAGE_NB_HITS_WITH_TIME_GENERATION]);
|
||||
}
|
||||
if (array_key_exists(Metrics::INDEX_PAGE_MIN_TIME_GENERATION, $row)) {
|
||||
unset($row[Metrics::INDEX_PAGE_MIN_TIME_GENERATION]);
|
||||
if (array_key_exists(PiwikMetrics::INDEX_PAGE_MIN_TIME_GENERATION, $row)) {
|
||||
unset($row[PiwikMetrics::INDEX_PAGE_MIN_TIME_GENERATION]);
|
||||
}
|
||||
if (array_key_exists(Metrics::INDEX_PAGE_MAX_TIME_GENERATION, $row)) {
|
||||
unset($row[Metrics::INDEX_PAGE_MAX_TIME_GENERATION]);
|
||||
if (array_key_exists(PiwikMetrics::INDEX_PAGE_MAX_TIME_GENERATION, $row)) {
|
||||
unset($row[PiwikMetrics::INDEX_PAGE_MAX_TIME_GENERATION]);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -147,7 +150,7 @@ class ArchivingHelper
|
|||
// - this happens when 2 visitors visit the same new page at the same time, and 2 actions get recorded for the same name
|
||||
// - this could also happen when 2 URLs end up having the same label (eg. 2 subdomains get aggregated to the "/index" page name)
|
||||
if (($alreadyValue = $actionRow->getColumn($name)) !== false) {
|
||||
$newValue = self::getColumnValuesMerged($name, $alreadyValue, $value);
|
||||
$newValue = self::getColumnValuesMerged($name, $alreadyValue, $value, $metricsConfig);
|
||||
$actionRow->setColumn($name, $newValue);
|
||||
} else {
|
||||
$actionRow->addColumn($name, $value);
|
||||
|
|
@ -157,7 +160,7 @@ class ArchivingHelper
|
|||
// if the exit_action was not recorded properly in the log_link_visit_action
|
||||
// there would be an error message when getting the nb_hits column
|
||||
// we must fake the record and add the columns
|
||||
if ($actionRow->getColumn(Metrics::INDEX_PAGE_NB_HITS) === false) {
|
||||
if ($actionRow->getColumn(PiwikMetrics::INDEX_PAGE_NB_HITS) === false) {
|
||||
// to test this code: delete the entries in log_link_action_visit for
|
||||
// a given exit_idaction_url
|
||||
foreach (self::getDefaultRow()->getColumns() as $name => $value) {
|
||||
|
|
@ -176,7 +179,7 @@ class ArchivingHelper
|
|||
{
|
||||
// Delete all columns that have a value of zero
|
||||
$dataTable->filter('ColumnDelete', array(
|
||||
$columnsToRemove = array(Metrics::INDEX_PAGE_IS_FOLLOWING_SITE_SEARCH_NB_HITS),
|
||||
$columnsToRemove = array(PiwikMetrics::INDEX_PAGE_IS_FOLLOWING_SITE_SEARCH_NB_HITS),
|
||||
$columnsToKeep = array(),
|
||||
$deleteIfZeroOnly = true
|
||||
));
|
||||
|
|
@ -194,16 +197,16 @@ class ArchivingHelper
|
|||
if (($idSubtable = $row->getIdSubDataTable()) !== null
|
||||
|| $id === DataTable::ID_SUMMARY_ROW
|
||||
) {
|
||||
if ($idSubtable !== null) {
|
||||
$subtable = Manager::getInstance()->getTable($idSubtable);
|
||||
self::deleteInvalidSummedColumnsFromDataTable($subtable);
|
||||
$subTable = $row->getSubtable();
|
||||
if ($subTable) {
|
||||
self::deleteInvalidSummedColumnsFromDataTable($subTable);
|
||||
}
|
||||
|
||||
if ($row instanceof DataTableSummaryRow) {
|
||||
$row->recalculate();
|
||||
}
|
||||
|
||||
foreach (Archiver::$columnsToDeleteAfterAggregation as $name) {
|
||||
foreach (Metrics::$columnsToDeleteAfterAggregation as $name) {
|
||||
$row->deleteColumn($name);
|
||||
}
|
||||
}
|
||||
|
|
@ -263,38 +266,45 @@ class ArchivingHelper
|
|||
* @param $value
|
||||
* @return mixed
|
||||
*/
|
||||
private static function getColumnValuesMerged($columnName, $alreadyValue, $value)
|
||||
private static function getColumnValuesMerged($columnName, $alreadyValue, $value, $metricsConfig)
|
||||
{
|
||||
if ($columnName == Metrics::INDEX_PAGE_MIN_TIME_GENERATION) {
|
||||
if (empty($alreadyValue)) {
|
||||
$newValue = $value;
|
||||
} else if (empty($value)) {
|
||||
$newValue = $alreadyValue;
|
||||
} else {
|
||||
$newValue = min($alreadyValue, $value);
|
||||
if (array_key_exists($columnName, $metricsConfig)) {
|
||||
$config = $metricsConfig[$columnName];
|
||||
|
||||
if (!empty($config['aggregation'])) {
|
||||
|
||||
if ($config['aggregation'] == 'min') {
|
||||
if (empty($alreadyValue)) {
|
||||
$newValue = $value;
|
||||
} else if (empty($value)) {
|
||||
$newValue = $alreadyValue;
|
||||
} else {
|
||||
$newValue = min($alreadyValue, $value);
|
||||
}
|
||||
return $newValue;
|
||||
}
|
||||
if ($config['aggregation'] == 'max') {
|
||||
$newValue = max($alreadyValue, $value);
|
||||
return $newValue;
|
||||
}
|
||||
}
|
||||
return $newValue;
|
||||
}
|
||||
if ($columnName == Metrics::INDEX_PAGE_MAX_TIME_GENERATION) {
|
||||
$newValue = max($alreadyValue, $value);
|
||||
return $newValue;
|
||||
}
|
||||
|
||||
$newValue = $alreadyValue + $value;
|
||||
return $newValue;
|
||||
}
|
||||
|
||||
static public $maximumRowsInDataTableLevelZero;
|
||||
static public $maximumRowsInSubDataTable;
|
||||
static public $columnToSortByBeforeTruncation;
|
||||
public static $maximumRowsInDataTableLevelZero;
|
||||
public static $maximumRowsInSubDataTable;
|
||||
public static $columnToSortByBeforeTruncation;
|
||||
|
||||
static protected $actionUrlCategoryDelimiter = null;
|
||||
static protected $actionTitleCategoryDelimiter = null;
|
||||
static protected $defaultActionName = null;
|
||||
static protected $defaultActionNameWhenNotDefined = null;
|
||||
static protected $defaultActionUrlWhenNotDefined = null;
|
||||
protected static $actionUrlCategoryDelimiter = null;
|
||||
protected static $actionTitleCategoryDelimiter = null;
|
||||
protected static $defaultActionName = null;
|
||||
protected static $defaultActionNameWhenNotDefined = null;
|
||||
protected static $defaultActionUrlWhenNotDefined = null;
|
||||
|
||||
static public function reloadConfig()
|
||||
public static function reloadConfig()
|
||||
{
|
||||
// for BC, we read the old style delimiter first (see #1067)Row
|
||||
$actionDelimiter = @Config::getInstance()->General['action_category_delimiter'];
|
||||
|
|
@ -306,7 +316,7 @@ class ArchivingHelper
|
|||
}
|
||||
|
||||
self::$defaultActionName = Config::getInstance()->General['action_default_name'];
|
||||
self::$columnToSortByBeforeTruncation = Metrics::INDEX_NB_VISITS;
|
||||
self::$columnToSortByBeforeTruncation = PiwikMetrics::INDEX_NB_VISITS;
|
||||
self::$maximumRowsInDataTableLevelZero = Config::getInstance()->General['datatable_archiving_maximum_rows_actions'];
|
||||
self::$maximumRowsInSubDataTable = Config::getInstance()->General['datatable_archiving_maximum_rows_subtable_actions'];
|
||||
|
||||
|
|
@ -320,7 +330,7 @@ class ArchivingHelper
|
|||
*
|
||||
* @return Row
|
||||
*/
|
||||
static private function getDefaultRow()
|
||||
private static function getDefaultRow()
|
||||
{
|
||||
static $row = false;
|
||||
if ($row === false) {
|
||||
|
|
@ -329,9 +339,9 @@ class ArchivingHelper
|
|||
// so we add this fake row information to make sure there is a nb_hits, etc. column for every action
|
||||
$row = new Row(array(
|
||||
Row::COLUMNS => array(
|
||||
Metrics::INDEX_NB_VISITS => 1,
|
||||
Metrics::INDEX_NB_UNIQ_VISITORS => 1,
|
||||
Metrics::INDEX_PAGE_NB_HITS => 1,
|
||||
PiwikMetrics::INDEX_NB_VISITS => 1,
|
||||
PiwikMetrics::INDEX_NB_UNIQ_VISITORS => 1,
|
||||
PiwikMetrics::INDEX_PAGE_NB_HITS => 1,
|
||||
)));
|
||||
}
|
||||
return $row;
|
||||
|
|
@ -347,13 +357,13 @@ class ArchivingHelper
|
|||
* @param array $actionsTablesByType
|
||||
* @return DataTable
|
||||
*/
|
||||
private static function getActionRow($actionName, $actionType, $urlPrefix = null, &$actionsTablesByType)
|
||||
public static function getActionRow($actionName, $actionType, $urlPrefix = null, &$actionsTablesByType)
|
||||
{
|
||||
// we work on the root table of the given TYPE (either ACTION_URL or DOWNLOAD or OUTLINK etc.)
|
||||
/* @var DataTable $currentTable */
|
||||
$currentTable =& $actionsTablesByType[$actionType];
|
||||
|
||||
if(is_null($currentTable)) {
|
||||
if (is_null($currentTable)) {
|
||||
throw new \Exception("Action table for type '$actionType' was not found during Actions archiving.");
|
||||
}
|
||||
|
||||
|
|
@ -390,7 +400,7 @@ class ArchivingHelper
|
|||
* @param $type
|
||||
* @return string
|
||||
*/
|
||||
static public function getUnknownActionName($type)
|
||||
public static function getUnknownActionName($type)
|
||||
{
|
||||
if (empty(self::$defaultActionNameWhenNotDefined)) {
|
||||
self::$defaultActionNameWhenNotDefined = Piwik::translate('General_NotDefined', Piwik::translate('Actions_ColumnPageName'));
|
||||
|
|
@ -402,7 +412,6 @@ class ArchivingHelper
|
|||
return self::$defaultActionUrlWhenNotDefined;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Explodes action name into an array of elements.
|
||||
*
|
||||
|
|
@ -425,7 +434,7 @@ class ArchivingHelper
|
|||
* @param int $urlPrefix url prefix (only used for TYPE_PAGE_URL)
|
||||
* @return array of exploded elements from $name
|
||||
*/
|
||||
static public function getActionExplodedNames($name, $type, $urlPrefix = null)
|
||||
public static function getActionExplodedNames($name, $type, $urlPrefix = null)
|
||||
{
|
||||
// Site Search does not split Search keywords
|
||||
if ($type == Action::TYPE_SITE_SEARCH) {
|
||||
|
|
@ -477,7 +486,7 @@ class ArchivingHelper
|
|||
/**
|
||||
* Static cache to store Rows during processing
|
||||
*/
|
||||
static protected $cacheParsedAction = array();
|
||||
protected static $cacheParsedAction = array();
|
||||
|
||||
public static function clearActionsCache()
|
||||
{
|
||||
|
|
@ -526,10 +535,10 @@ class ArchivingHelper
|
|||
*/
|
||||
private static function getDefaultRowColumns()
|
||||
{
|
||||
return array(Metrics::INDEX_NB_VISITS => 0,
|
||||
Metrics::INDEX_NB_UNIQ_VISITORS => 0,
|
||||
Metrics::INDEX_PAGE_NB_HITS => 0,
|
||||
Metrics::INDEX_PAGE_SUM_TIME_SPENT => 0);
|
||||
return array(PiwikMetrics::INDEX_NB_VISITS => 0,
|
||||
PiwikMetrics::INDEX_NB_UNIQ_VISITORS => 0,
|
||||
PiwikMetrics::INDEX_PAGE_NB_HITS => 0,
|
||||
PiwikMetrics::INDEX_PAGE_SUM_TIME_SPENT => 0);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -594,7 +603,12 @@ class ArchivingHelper
|
|||
$urlFragment = $matches[3];
|
||||
|
||||
if (in_array($type, array(Action::TYPE_DOWNLOAD, Action::TYPE_OUTLINK))) {
|
||||
return array(trim($urlHost), '/' . trim($urlPath));
|
||||
$path = '/' . trim($urlPath);
|
||||
if (!empty($urlFragment)) {
|
||||
$path .= '#' . $urlFragment;
|
||||
}
|
||||
|
||||
return array(trim($urlHost), $path);
|
||||
}
|
||||
|
||||
$name = $urlPath;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue