diff options
author | mattab <matthieu.aubry@gmail.com> | 2014-09-08 07:30:56 +0400 |
---|---|---|
committer | mattab <matthieu.aubry@gmail.com> | 2014-09-08 07:30:56 +0400 |
commit | e2b61f5dd767b1606f99826ba060fccbe1ba674c (patch) | |
tree | 339a647c4bd49bbdbf41618ad828f4e555fbd34e /core | |
parent | 8a0a7d80571d57bcef947e6006eb4be97ba02150 (diff) |
Refs #3490 Adding segment 'userId==' + some '&segment=userId==' integration tests + doc blocks
Diffstat (limited to 'core')
-rw-r--r-- | core/Common.php | 12 | ||||
-rw-r--r-- | core/Tracker/Request.php | 15 |
2 files changed, 25 insertions, 2 deletions
diff --git a/core/Common.php b/core/Common.php index ecfefabcec..5d5c35c764 100644 --- a/core/Common.php +++ b/core/Common.php @@ -575,6 +575,18 @@ class Common } /** + * Converts a User ID string to the Visitor ID Binary representation. + * + * @param $userId + * @return string + */ + public static function convertUserIdToVisitorIdBin($userId) + { + $userIdHashed = \PiwikTracker::getUserIdHashed($userId); + return self::convertVisitorIdToBin($userIdHashed); + } + + /** * Convert IP address (in network address format) to presentation format. * This is a backward compatibility function for code that only expects * IPv4 addresses (i.e., doesn't support IPv6). diff --git a/core/Tracker/Request.php b/core/Tracker/Request.php index eddc99786e..239feb7ed7 100644 --- a/core/Tracker/Request.php +++ b/core/Tracker/Request.php @@ -450,8 +450,8 @@ class Request // If User ID is set it takes precedence $userId = $this->getForcedUserId(); if(strlen($userId) > 0) { - $idVisitor = md5($userId); - $idVisitor = $this->truncateIdAsVisitorId($idVisitor); + $userIdHashed = $this->getUserIdHashed($userId); + $idVisitor = $this->truncateIdAsVisitorId($userIdHashed); Common::printDebug("Request will be recorded for this user_id = " . $userId . " (idvisitor = $idVisitor)"); $found = true; } @@ -573,4 +573,15 @@ class Request { return substr($idVisitor, 0, Tracker::LENGTH_HEX_ID_STRING); } + + /** + * Matches implementation of PiwikTracker::getUserIdHashed + * + * @param $userId + * @return string + */ + private function getUserIdHashed($userId) + { + return sha1($userId); + } } |