diff --git a/core/Columns/Updater.php b/core/Columns/Updater.php
index 1fa6320685316828e2ca248b4f75dcaef566f502..2dd6e4040e8e55ea5552092c580803f04eab0167 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 659c5fac6acf5e446ceb1448c5b229a096dac328..b34ee88709477a15245967d56b0705d5fe1d826f 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 846c7c78acfaf9810caf08ff0b1922532d187a7e..b4120781516bc9ae02b536ea08b470bbe6241e4e 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 64d867fe64f931df35eaec9c7e1616e91e8377e9..146a7ea4c68a1e2d1d6264b0b10cdb8bf537e39b 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 82ec03ae540a6118c338df6e2c8ad5b8771f9001..745bfb2f8152352e611697c91e1aed63cba62aeb 160000
--- a/tests/PHPUnit/UI
+++ b/tests/PHPUnit/UI
@@ -1 +1 @@
-Subproject commit 82ec03ae540a6118c338df6e2c8ad5b8771f9001
+Subproject commit 745bfb2f8152352e611697c91e1aed63cba62aeb