diff options
author | Thomas Steur <thomas.steur@gmail.com> | 2015-12-07 06:04:40 +0300 |
---|---|---|
committer | Thomas Steur <thomas.steur@gmail.com> | 2015-12-07 06:04:40 +0300 |
commit | 39c6118fb63352dfe3691e55a5aaeba950f66a4b (patch) | |
tree | 1baf310b6cdd251c9de45ffa7d39581e5f572a8e | |
parent | 8344b1a4999289a69e12f392f9f080125fd894d0 (diff) |
fix error table log_visit is already joined in https://github.com/piwik/plugin-CustomDimensions/pull/19
-rw-r--r-- | core/DataAccess/LogQueryBuilder.php | 13 | ||||
-rw-r--r-- | tests/PHPUnit/Integration/SegmentTest.php | 3 |
2 files changed, 14 insertions, 2 deletions
diff --git a/core/DataAccess/LogQueryBuilder.php b/core/DataAccess/LogQueryBuilder.php index f55fd96a56..c491b934ce 100644 --- a/core/DataAccess/LogQueryBuilder.php +++ b/core/DataAccess/LogQueryBuilder.php @@ -102,7 +102,6 @@ class LogQueryBuilder $tables[$actionIndex] = "log_conversion"; $tables[$conversionIndex] = "log_link_visit_action"; } - // same as above: action before visit $actionIndex = array_search("log_link_visit_action", $tables); $visitIndex = array_search("log_visit", $tables); @@ -169,11 +168,23 @@ class LogQueryBuilder } elseif ($linkVisitActionsTableAvailable && $table == "log_visit") { // have actions, need visits => join on idvisit $join = "log_visit.idvisit = log_link_visit_action.idvisit"; + + if ($this->hasJoinedTableAlreadyManually($table, $join, $tables)) { + $visitsAvailable = true; + continue; + } + } elseif ($visitsAvailable && $table == "log_link_visit_action") { // have visits, need actions => we have to use a more complex join // we don't hande this here, we just return joinWithSubSelect=true in this case $joinWithSubSelect = true; $join = "log_link_visit_action.idvisit = log_visit.idvisit"; + + if ($this->hasJoinedTableAlreadyManually($table, $join, $tables)) { + $linkVisitActionsTableAvailable = true; + continue; + } + } elseif ($conversionsAvailable && $table == "log_link_visit_action") { // have conversions, need actions => join on idvisit $join = "log_conversion.idvisit = log_link_visit_action.idvisit"; diff --git a/tests/PHPUnit/Integration/SegmentTest.php b/tests/PHPUnit/Integration/SegmentTest.php index d5fce5f7e4..eccd355ee3 100644 --- a/tests/PHPUnit/Integration/SegmentTest.php +++ b/tests/PHPUnit/Integration/SegmentTest.php @@ -382,7 +382,8 @@ class SegmentTest extends IntegrationTestCase $from = array( 'log_link_visit_action', array('table' => 'log_visit', 'joinOn' => 'log_visit.idvisit = log_link_visit_action.idvisit'), - array('table' => 'log_action', 'joinOn' => 'log_link_visit_action.idaction_url = log_action.idaction') + array('table' => 'log_action', 'joinOn' => 'log_link_visit_action.idaction_url = log_action.idaction'), + 'log_visit' ); $where = 'log_link_visit_action.server_time >= ? AND log_link_visit_action.server_time <= ? |