Skip to content

Commit

Permalink
refs #4996 tests should now work in case Piwik is installed in a subd…
Browse files Browse the repository at this point in the history
…irectory although could not really test it. Also encode redirect uri
  • Loading branch information
tsteur committed Sep 15, 2014
1 parent b03f7c8 commit 566cdbd
Show file tree
Hide file tree
Showing 5 changed files with 81 additions and 66 deletions.
34 changes: 22 additions & 12 deletions core/Tracker.php
Expand Up @@ -10,7 +10,7 @@

use Exception;
use Piwik\Plugins\PrivacyManager\Config as PrivacyManagerConfig;
use Piwik\Plugins\SitesManager\Model;
use Piwik\Plugins\SitesManager\SiteUrls;
use Piwik\Tracker\Cache;
use Piwik\Tracker\Db\DbException;
use Piwik\Tracker\Db\Mysqli;
Expand Down Expand Up @@ -940,24 +940,34 @@ private function performRedirectToUrlIfSet()
return;
}

$siteIds = array();

foreach ($this->requests as $request) {
$siteIds[] = (int) $request['idsite'];
}

$siteIds = array_unique($siteIds);

$model = new Model();
$urls = new SiteUrls();
$siteUrls = $urls->getAllCachedSiteUrls();
$siteIds = $this->getAllSiteIdsWithinRequest();

foreach ($siteIds as $siteId) {
$siteUrls = $model->getSiteUrlsFromId($siteId);
if (empty($siteUrls[$siteId])) {
continue;
}

if (Url::isHostInUrls($host, $siteUrls)) {
if (Url::isHostInUrls($host, $siteUrls[$siteId])) {
Url::redirectToUrl($redirectUrl);
}
}
}

private function getAllSiteIdsWithinRequest()
{
if (empty($this->requests)) {
return array();
}

$siteIds = array();

foreach ($this->requests as $request) {
$siteIds[] = (int) $request['idsite'];
}

return array_unique($siteIds);
}

}
2 changes: 1 addition & 1 deletion js/piwik.js
Expand Up @@ -3197,7 +3197,7 @@ if (typeof Piwik !== 'object') {
}

var redirectUrl = content.toAbsoluteUrl(url);
var request = 'redirecturl=' + redirectUrl + '&';
var request = 'redirecturl=' + encodeWrapper(redirectUrl) + '&';
request += buildContentInteractionRequest(contentInteraction, contentName, contentPiece, (contentTarget || url));

var separator = '&';
Expand Down
1 change: 0 additions & 1 deletion misc/internal-docs/content-tracking.md
Expand Up @@ -434,7 +434,6 @@ Nothing special here I think. We would probably automatically detect the type of
* Maybe v2
* Content piece undefined vs Unknown?
* UI / PHP tests
* Make JS tests work if piwik is installed in a path such as localhost/piwik

## V2:
* "note: as a user, I see that piwik.php redirects is the default "click tracking" solution, but I want to be able to disable this piwik.php redirect and instead use the link tracking 500ms solution."
Expand Down
2 changes: 1 addition & 1 deletion piwik.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 566cdbd

Please sign in to comment.