diff options
author | mattab <matthieu.aubry@gmail.com> | 2014-10-01 07:26:52 +0400 |
---|---|---|
committer | mattab <matthieu.aubry@gmail.com> | 2014-10-01 07:26:52 +0400 |
commit | cd1b52dd2e5807d2871e6037815cae2390c5243d (patch) | |
tree | 5e5ff7f877d60f8d477f9d21cf5b2d659acea68a /core/Tracker/Visitor.php | |
parent | 2cd5f09a52fe28ff644827a58ce0f88f177b3f7e (diff) |
Fixes #6313 - When a user starts to get a User ID set, then we set this User ID to the existing visit rather than create a new visit for this user id specifically
Diffstat (limited to 'core/Tracker/Visitor.php')
-rw-r--r-- | core/Tracker/Visitor.php | 26 |
1 files changed, 18 insertions, 8 deletions
diff --git a/core/Tracker/Visitor.php b/core/Tracker/Visitor.php index a73361e014..ec5dd6d279 100644 --- a/core/Tracker/Visitor.php +++ b/core/Tracker/Visitor.php @@ -118,7 +118,8 @@ class Visitor // We use a UNION here so that each sql query uses its own INDEX else { // will use INDEX index_idsite_config_datetime (idsite, config_id, visit_last_action_time) - $where = ' AND config_id = ?'; + $where = ' AND config_id = ? + AND user_id IS NULL '; $bindSql[] = $configId; $sqlConfigId = "$select , 0 as priority @@ -226,22 +227,31 @@ class Visitor protected function shouldLookupOneVisitorFieldOnly($isVisitorIdToLookup) { + $isForcedUserIdMustMatch = (false !== $this->request->getForcedUserId()); + if($isForcedUserIdMustMatch) { + // if &iud was set, we must try and match both idvisitor and config_id + return false; + } + // This setting would be enabled for Intranet websites, to ensure that visitors using all the same computer config, same IP // are not counted as 1 visitor. In this case, we want to enforce and trust the visitor ID from the cookie. $trustCookiesOnly = Config::getInstance()->Tracker['trust_visitors_cookies']; + if($isVisitorIdToLookup && $trustCookiesOnly) { + return true; + } // If a &cid= was set, we force to select this visitor (or create a new one) $isForcedVisitorIdMustMatch = ($this->request->getForcedVisitorId() != null); - // if &iud was set, we force to select this visitor (or create new one) - $isForcedUserIdMustMatch = ($this->request->getForcedUserId() !== null); + if($isForcedVisitorIdMustMatch) { + return true; + } - $shouldMatchOneFieldOnly = (($isVisitorIdToLookup && $trustCookiesOnly) - || $isForcedVisitorIdMustMatch - || $isForcedUserIdMustMatch - || !$isVisitorIdToLookup); + if( !$isVisitorIdToLookup ) { + return true; + } - return $shouldMatchOneFieldOnly; + return false; } /** |