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:
Diffstat (limited to 'core/DataTable/Row.php')
-rw-r--r--core/DataTable/Row.php16
1 files changed, 12 insertions, 4 deletions
diff --git a/core/DataTable/Row.php b/core/DataTable/Row.php
index 3bd3b023d8..4077d6cd43 100644
--- a/core/DataTable/Row.php
+++ b/core/DataTable/Row.php
@@ -462,7 +462,11 @@ class Row extends \ArrayObject
$operation = 'sum';
if (is_array($aggregationOperations) && isset($aggregationOperations[$columnToSumName])) {
- $operation = strtolower($aggregationOperations[$columnToSumName]);
+ if (is_string($aggregationOperations[$columnToSumName])) {
+ $operation = strtolower($aggregationOperations[$columnToSumName]);
+ } elseif (is_callable($aggregationOperations[$columnToSumName])) {
+ $operation = $aggregationOperations[$columnToSumName];
+ }
}
// max_actions is a core metric that is generated in ArchiveProcess_Day. Therefore, it can be
@@ -474,7 +478,7 @@ class Row extends \ArrayObject
throw new Exception("Unknown aggregation operation for column $columnToSumName.");
}
- $newValue = $this->getColumnValuesMerged($operation, $thisColumnValue, $columnToSumValue);
+ $newValue = $this->getColumnValuesMerged($operation, $thisColumnValue, $columnToSumValue, $this, $rowToSum);
$this->setColumn($columnToSumName, $newValue);
}
@@ -486,7 +490,7 @@ class Row extends \ArrayObject
/**
*/
- private function getColumnValuesMerged($operation, $thisColumnValue, $columnToSumValue)
+ private function getColumnValuesMerged($operation, $thisColumnValue, $columnToSumValue, $thisRow, $rowToSum)
{
switch ($operation) {
case 'skip':
@@ -521,6 +525,10 @@ class Row extends \ArrayObject
$newValue = $thisColumnValue;
break;
default:
+ if (is_callable($operation)) {
+ return call_user_func($operation, $thisColumnValue, $columnToSumValue, $thisRow, $rowToSum);
+ }
+
throw new Exception("Unknown operation '$operation'.");
}
return $newValue;
@@ -549,7 +557,7 @@ class Row extends \ArrayObject
continue;
}
- $aggregatedMetadata[$columnn] = $this->getColumnValuesMerged($operation, $thisMetadata, $sumMetadata);
+ $aggregatedMetadata[$columnn] = $this->getColumnValuesMerged($operation, $thisMetadata, $sumMetadata, $this, $rowToSum);
}
}