From 7ab1d826a20bfec0f9e63b165c8bb7d5d22decca Mon Sep 17 00:00:00 2001 From: mattab <matthieu.aubry@gmail.com> Date: Tue, 23 Sep 2014 20:50:00 +1200 Subject: [PATCH] User ID is NULLable refs #3490 --- core/Columns/Updater.php | 2 +- core/Tracker/Request.php | 8 ++++++-- core/Tracker/Visitor.php | 2 +- plugins/CoreHome/Columns/UserId.php | 4 ++-- tests/PHPUnit/UI | 2 +- 5 files changed, 11 insertions(+), 7 deletions(-) diff --git a/core/Columns/Updater.php b/core/Columns/Updater.php index 1fa6320685..2dd6e4040e 100644 --- a/core/Columns/Updater.php +++ b/core/Columns/Updater.php @@ -268,7 +268,7 @@ class Updater extends \Piwik\Updates 'log_visit.referer_keyword' => 'VARCHAR(255) NULL1', 'log_visit.referer_name' => 'VARCHAR(70) NULL1', 'log_visit.referer_type' => 'TINYINT(1) UNSIGNED NULL1', - 'log_visit.user_id' => 'VARCHAR(200) NOT NULL', + 'log_visit.user_id' => 'VARCHAR(200) NULL', 'log_link_visit_action.idaction_name' => 'INTEGER(10) UNSIGNED', 'log_link_visit_action.idaction_url' => 'INTEGER(10) UNSIGNED DEFAULT NULL', 'log_link_visit_action.server_time' => 'DATETIME NOT NULL', diff --git a/core/Tracker/Request.php b/core/Tracker/Request.php index 659c5fac6a..b34ee88709 100644 --- a/core/Tracker/Request.php +++ b/core/Tracker/Request.php @@ -455,7 +455,7 @@ class Request // If User ID is set it takes precedence $userId = $this->getForcedUserId(); - if(strlen($userId) > 0) { + if($userId) { $userIdHashed = $this->getUserIdHashed($userId); $idVisitor = $this->truncateIdAsVisitorId($userIdHashed); Common::printDebug("Request will be recorded for this user_id = " . $userId . " (idvisitor = $idVisitor)"); @@ -535,7 +535,11 @@ class Request public function getForcedUserId() { - return $this->getParam('uid'); + $userId = $this->getParam('uid'); + if(strlen($userId) > 0) { + return $userId; + } + return null; } public function getForcedVisitorId() diff --git a/core/Tracker/Visitor.php b/core/Tracker/Visitor.php index 846c7c78ac..b412078151 100644 --- a/core/Tracker/Visitor.php +++ b/core/Tracker/Visitor.php @@ -234,7 +234,7 @@ class Visitor $isForcedVisitorIdMustMatch = ($this->request->getForcedVisitorId() != null); // if &iud was set, we force to select this visitor (or create new one) - $isForcedUserIdMustMatch = ($this->request->getForcedUserId() != null); + $isForcedUserIdMustMatch = ($this->request->getForcedUserId() !== null); $shouldMatchOneFieldOnly = (($isVisitorIdToLookup && $trustCookiesOnly) || $isForcedVisitorIdMustMatch diff --git a/plugins/CoreHome/Columns/UserId.php b/plugins/CoreHome/Columns/UserId.php index 64d867fe64..146a7ea4c6 100644 --- a/plugins/CoreHome/Columns/UserId.php +++ b/plugins/CoreHome/Columns/UserId.php @@ -26,7 +26,7 @@ class UserId extends VisitDimension /** * @var string */ - protected $columnType = 'VARCHAR(200) NOT NULL'; + protected $columnType = 'VARCHAR(200) NULL'; /** * @param Request $request @@ -49,7 +49,7 @@ class UserId extends VisitDimension public function onExistingVisit(Request $request, Visitor $visitor, $action) { $forcedUserId = $request->getForcedUserId(); - if (strlen($forcedUserId) > 0) { + if ($forcedUserId) { return $forcedUserId; } diff --git a/tests/PHPUnit/UI b/tests/PHPUnit/UI index 82ec03ae54..745bfb2f81 160000 --- a/tests/PHPUnit/UI +++ b/tests/PHPUnit/UI @@ -1 +1 @@ -Subproject commit 82ec03ae540a6118c338df6e2c8ad5b8771f9001 +Subproject commit 745bfb2f8152352e611697c91e1aed63cba62aeb -- GitLab