diff options
author | mattab <matthieu.aubry@gmail.com> | 2014-02-17 03:31:21 +0400 |
---|---|---|
committer | mattab <matthieu.aubry@gmail.com> | 2014-02-17 03:31:21 +0400 |
commit | 07305105e4c5050412be11f914d58d0e840e9912 (patch) | |
tree | 604e5219b6b7cd6b46fd8c3489f045cd0070fa67 /core/DataArray.php | |
parent | 3a4c64be7c391bb9250a1df290ade56a24417146 (diff) |
Fixes #4687 Initializes the row values so this works without errors even in this edge case. I couldn't easily reproduce this error in a test, so just fixing the bug as is.
Diffstat (limited to 'core/DataArray.php')
-rw-r--r-- | core/DataArray.php | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/core/DataArray.php b/core/DataArray.php index 87748f2ed4..ab14526f4e 100644 --- a/core/DataArray.php +++ b/core/DataArray.php @@ -104,6 +104,18 @@ class DataArray return; } + // In case the existing Row had no action metrics (eg. Custom Variable XYZ with "visit" scope) + // but the new Row has action metrics (eg. same Custom Variable XYZ this time with a "page" scope) + if(!isset($oldRowToUpdate[Metrics::INDEX_MAX_ACTIONS])) { + $toZero = array(Metrics::INDEX_MAX_ACTIONS, + Metrics::INDEX_SUM_VISIT_LENGTH, + Metrics::INDEX_BOUNCE_COUNT, + Metrics::INDEX_NB_VISITS_CONVERTED); + foreach($toZero as $metric) { + $oldRowToUpdate[$metric] = 0; + } + } + $oldRowToUpdate[Metrics::INDEX_MAX_ACTIONS] = (float)max($newRowToAdd[Metrics::INDEX_MAX_ACTIONS], $oldRowToUpdate[Metrics::INDEX_MAX_ACTIONS]); $oldRowToUpdate[Metrics::INDEX_SUM_VISIT_LENGTH] += $newRowToAdd[Metrics::INDEX_SUM_VISIT_LENGTH]; $oldRowToUpdate[Metrics::INDEX_BOUNCE_COUNT] += $newRowToAdd[Metrics::INDEX_BOUNCE_COUNT]; |