Skip to content

Commit

Permalink
Prevent notice in tracker code generator (#15057)
Browse files Browse the repository at this point in the history
* Prevent notice in tracker code generator

> /core/Tracker/TrackerCodeGenerator.php(254): Notice - Undefined index: host - Matomo 3.11.0

Eg happens from what I can see when no main url is defined

* Update TrackerCodeGenerator.php
  • Loading branch information
tsteur authored and diosmosis committed Nov 6, 2019
1 parent 42722e3 commit ffd9845
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions core/Tracker/TrackerCodeGenerator.php
Original file line number Diff line number Diff line change
Expand Up @@ -245,17 +245,28 @@ private function getJavascriptTagOptions($idSite, $mergeSubdomains, $mergeAliasU
$websiteHosts = array();
$firstHost = null;
foreach ($websiteUrls as $site_url) {
if (empty($site_url)) {
continue;
}

$referrerParsed = parse_url($site_url);

if (!isset($firstHost) && isset($referrerParsed['host'])) {
$firstHost = $referrerParsed['host'];
}

$url = $referrerParsed['host'];
if (isset($referrerParsed['host'])) {
$url = $referrerParsed['host'];
} else {
$url = '';
}
if (!empty($referrerParsed['path'])) {
$url .= $referrerParsed['path'];
}
$websiteHosts[] = $url;

if (!empty($url)) {
$websiteHosts[] = $url;
}
}
$options = '';
if ($mergeSubdomains && !empty($firstHost)) {
Expand Down

0 comments on commit ffd9845

Please sign in to comment.