From 1c2502b38aeeac68bce6fc411e683b2fd8e61a92 Mon Sep 17 00:00:00 2001 From: Stefan Giehl Date: Thu, 24 Dec 2020 00:03:09 +0100 Subject: Improve action id lookup for segments (#16977) * Improve action id lookup fog segments if no id can be found for a segment with the normalized value, try looking it up the the original value * Adds UI test for opening vlog with outlink containing a & --- core/Tracker/TableLogAction.php | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) (limited to 'core') diff --git a/core/Tracker/TableLogAction.php b/core/Tracker/TableLogAction.php index fea4cac171..331239f3d9 100644 --- a/core/Tracker/TableLogAction.php +++ b/core/Tracker/TableLogAction.php @@ -43,7 +43,7 @@ class TableLogAction $actionIds = self::queryIdsAction($actionsNameAndType); - list($queriedIds, $fieldNamesToInsert) = self::processIdsToInsert($actionsNameAndType, $actionIds); + [$queriedIds, $fieldNamesToInsert] = self::processIdsToInsert($actionsNameAndType, $actionIds); $insertedIds = self::insertNewIdsAction($actionsNameAndType, $fieldNamesToInsert); $queriedIds = $queriedIds + $insertedIds; @@ -95,7 +95,7 @@ class TableLogAction $inserted = array(); foreach ($fieldNamesToInsert as $fieldName) { - list($name, $type, $urlPrefix) = $actionsNameAndType[$fieldName]; + [$name, $type, $urlPrefix] = $actionsNameAndType[$fieldName]; $actionId = self::getModel()->createNewIdAction($name, $type, $urlPrefix); @@ -116,7 +116,7 @@ class TableLogAction { $toQuery = array(); foreach ($actionsNameAndType as &$actionNameType) { - list($name, $type, $urlPrefix) = $actionNameType; + [$name, $type, $urlPrefix] = $actionNameType; $toQuery[] = array('name' => $name, 'type' => $type); } @@ -184,14 +184,20 @@ class TableLogAction $valueToMatch = preg_replace('@^http[s]?://(www\.)?@i', '', $valueToMatch); } + $unsanitizedValue = $valueToMatch; $valueToMatch = self::normaliseActionString($actionType, $valueToMatch); if ($matchType == SegmentExpression::MATCH_EQUAL || $matchType == SegmentExpression::MATCH_NOT_EQUAL ) { $idAction = self::getModel()->getIdActionMatchingNameAndType($valueToMatch, $actionType); - // Action is not found (eg. &segment=pageTitle==Větrnásssssss) + // If action can't be found normalized try search for it with original value + // This can eg happen for outlinks that contain a & see https://github.com/matomo-org/matomo/issues/11806 if (empty($idAction)) { - $idAction = null; + $idAction = self::getModel()->getIdActionMatchingNameAndType($unsanitizedValue, $actionType); + // Action is not found (eg. &segment=pageTitle==Větrnásssssss) + if (empty($idAction)) { + $idAction = null; + } } return $idAction; } -- cgit v1.2.3