Skip to content

Commit

Permalink
Refs PR #241 Manually close session when redirecting to another page
Browse files Browse the repository at this point in the history
  • Loading branch information
mattab committed May 5, 2014
1 parent f6c967d commit ccb1aaa
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 5 deletions.
4 changes: 2 additions & 2 deletions core/Plugin/Controller.php
Expand Up @@ -771,13 +771,13 @@ public function redirectToIndex($moduleToRedirect, $actionToRedirect, $websiteId
}

if ($websiteId) {
$url = "Location: index.php?module=" . $moduleToRedirect
$url = "index.php?module=" . $moduleToRedirect
. "&action=" . $actionToRedirect
. "&idSite=" . $websiteId
. "&period=" . $defaultPeriod
. "&date=" . $defaultDate
. $parametersString;
header($url);
Url::redirectToUrl($url);
exit;
}

Expand Down
7 changes: 6 additions & 1 deletion core/Session.php
Expand Up @@ -109,7 +109,7 @@ public static function start($options = false)
}

try {
Zend_Session::start();
parent::start();
register_shutdown_function(array('Zend_Session', 'writeClose'), true);
} catch (Exception $e) {
Log::warning('Unable to start session: ' . $e->getMessage());
Expand Down Expand Up @@ -143,4 +143,9 @@ public static function getSessionsDirectory()
$path = PIWIK_USER_PATH . '/tmp/sessions';
return SettingsPiwik::rewriteTmpPathWithHostname($path);
}

public static function close()
{
parent::writeClose($readonly);
}
}
5 changes: 5 additions & 0 deletions core/Url.php
Expand Up @@ -460,6 +460,11 @@ static public function redirectToReferrer()
*/
static public function redirectToUrl($url)
{
// Close the session manually.
// We should not have to call this because it was registered via register_shutdown_function,
// but it is not always called fast enough
Session::close();

if (UrlHelper::isLookLikeUrl($url)
|| strpos($url, 'index.php') === 0
) {
Expand Down
2 changes: 1 addition & 1 deletion plugins/CoreHome/Controller.php
Expand Up @@ -226,7 +226,7 @@ public function redirectToPaypal()

$url = "https://www.paypal.com/cgi-bin/webscr?" . Url::getQueryStringFromParameters($parameters);

header("Location: $url");
Url::redirectToUrl($url);
exit;
}

Expand Down
2 changes: 1 addition & 1 deletion tests/PHPUnit/UI
Submodule UI updated from 5a1919 to 65c2ef

0 comments on commit ccb1aaa

Please sign in to comment.