Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
tsteur committed Jan 1, 2020
1 parent cea95ef commit 1032eea
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 8 deletions.
24 changes: 17 additions & 7 deletions app/core/Tracker/Model.php
Original file line number Diff line number Diff line change
Expand Up @@ -366,7 +366,7 @@ public function updateAction($idLinkVa, $valuesToUpdate)
return $wasInserted;
}

public function findVisitor($idSite, $configId, $idVisitor, $fieldsToRead, $shouldMatchOneFieldOnly, $isVisitorIdToLookup, $timeLookBack, $timeLookAhead)
public function findVisitor($idSite, $configId, $idVisitor, $userId, $fieldsToRead, $shouldMatchOneFieldOnly, $isVisitorIdToLookup, $timeLookBack, $timeLookAhead)
{
$selectCustomVariables = '';

Expand Down Expand Up @@ -398,12 +398,22 @@ public function findVisitor($idSite, $configId, $idVisitor, $fieldsToRead, $shou
} elseif ($shouldMatchOneFieldOnly) {
$visitRow = $this->findVisitorByConfigId($configId, $select, $from, $configIdWhere, $configIdbindSql);
} else {
$visitRow = $this->findVisitorByVisitorId($idVisitor, $select, $from, $visitorIdWhere, $visitorIdbindSql);

if (empty($visitRow)) {
$configIdWhere .= ' AND user_id IS NULL ';
$visitRow = $this->findVisitorByConfigId($configId, $select, $from, $configIdWhere, $configIdbindSql);
}
if (!empty($idVisitor)) {
$visitRow = $this->findVisitorByVisitorId($idVisitor, $select, $from, $visitorIdWhere, $visitorIdbindSql);
} else {
$visitRow = false;
}

if (empty($visitRow)) {
$configIdWhere .= ' AND ( user_id IS NULL ';
if (!empty($userId)) {
$configIdWhere .= 'OR user_id = ? )';
$configIdbindSql[] = $userId;
} else {
$configIdWhere .= ')';
}
$visitRow = $this->findVisitorByConfigId($configId, $select, $from, $configIdWhere, $configIdbindSql);
}
}

return $visitRow;
Expand Down
3 changes: 2 additions & 1 deletion app/core/Tracker/VisitorRecognizer.php
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ public function findKnownVisitor($configId, VisitProperties $visitProperties, Re
{
$idSite = $request->getIdSite();
$idVisitor = $request->getVisitorId();
$userId = $request->getForcedUserId();

$isVisitorIdToLookup = !empty($idVisitor);

Expand All @@ -98,7 +99,7 @@ public function findKnownVisitor($configId, VisitProperties $visitProperties, Re
$shouldMatchOneFieldOnly = $this->shouldLookupOneVisitorFieldOnly($isVisitorIdToLookup, $request);
list($timeLookBack, $timeLookAhead) = $this->getWindowLookupThisVisit($request);

$visitRow = $this->model->findVisitor($idSite, $configId, $idVisitor, $persistedVisitAttributes, $shouldMatchOneFieldOnly, $isVisitorIdToLookup, $timeLookBack, $timeLookAhead);
$visitRow = $this->model->findVisitor($idSite, $configId, $idVisitor, $userId, $persistedVisitAttributes, $shouldMatchOneFieldOnly, $isVisitorIdToLookup, $timeLookBack, $timeLookAhead);
$this->visitRow = $visitRow;

if ($visitRow
Expand Down

0 comments on commit 1032eea

Please sign in to comment.