diff options
author | diosmosis <benaka@piwik.pro> | 2015-07-09 06:06:12 +0300 |
---|---|---|
committer | diosmosis <benaka@piwik.pro> | 2015-08-06 17:37:58 +0300 |
commit | 4b1b0757ff146837ec3ef8d928f37b04c1d17ac4 (patch) | |
tree | fdf80cfea4e5f715c046b907391d94aaf3b0a196 /plugins/Goals | |
parent | 9c722038a97e4676e9c66fe205c9bd8767e3591d (diff) |
Move visitor not found logic in Visit::handle() to Goals request processor.
Diffstat (limited to 'plugins/Goals')
-rw-r--r-- | plugins/Goals/Tracker/GoalsRequestProcessor.php | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/plugins/Goals/Tracker/GoalsRequestProcessor.php b/plugins/Goals/Tracker/GoalsRequestProcessor.php index 22315f7511..2bde947928 100644 --- a/plugins/Goals/Tracker/GoalsRequestProcessor.php +++ b/plugins/Goals/Tracker/GoalsRequestProcessor.php @@ -70,4 +70,26 @@ class GoalsRequestProcessor extends RequestProcessor $visitProperties->setRequestMetadata('Goals', 'visitIsConverted', $someGoalsConverted); } } + + public function processRequest(VisitProperties $visitProperties) + { + $isManualGoalConversion = self::$goalManager->isManualGoalConversion(); + $requestIsEcommerce = self::$goalManager->requestIsEcommerce; + + $visitorNotFoundInDb = $visitProperties->getRequestMetadata('CoreHome', 'visitorNotFoundInDb'); + + // There is an edge case when: + // - two manual goal conversions happen in the same second + // - which result in handleExistingVisit throwing the exception + // because the UPDATE didn't affect any rows (one row was found, but not updated since no field changed) + // - the exception is caught here and will result in a new visit incorrectly + // In this case, we cancel the current conversion to be recorded: + if ($visitorNotFoundInDb + && ($isManualGoalConversion + || $requestIsEcommerce) + ) { + $visitProperties->setRequestMetadata('Goals', 'someGoalsConverted', false); + $visitProperties->setRequestMetadata('Goals', 'visitIsConverted', false); + } + } } |