diff options
author | Thomas Steur <tsteur@users.noreply.github.com> | 2019-09-23 00:01:09 +0300 |
---|---|---|
committer | diosmosis <diosmosis@users.noreply.github.com> | 2019-09-23 00:01:09 +0300 |
commit | 83e025eede225579ce3120d3620f812fb037b3b2 (patch) | |
tree | 9e424d86ea94123d0793eaf5abb7f7b43ba55332 /core | |
parent | 6db4698f572d6500d461e5d2fca565dcf1e12932 (diff) |
If session was already started, do not start it again (#14896)
* If session was already started, do not start it again
refs https://github.com/matomo-org/matomo/issues/12963
refs https://forum.matomo.org/t/an-error-occurred/32500
* Update Session.php
* Update bootstrap.php
* add test
Diffstat (limited to 'core')
-rw-r--r-- | core/Session.php | 7 | ||||
-rw-r--r-- | core/bootstrap.php | 4 |
2 files changed, 9 insertions, 2 deletions
diff --git a/core/Session.php b/core/Session.php index c916893706..024c5246d8 100644 --- a/core/Session.php +++ b/core/Session.php @@ -50,6 +50,7 @@ class Session extends Zend_Session if (headers_sent() || self::$sessionStarted || (defined('PIWIK_ENABLE_SESSION_START') && !PIWIK_ENABLE_SESSION_START) + || session_status() == PHP_SESSION_ACTIVE ) { return; } @@ -173,7 +174,11 @@ class Session extends Zend_Session public static function close() { - parent::writeClose(); + if (self::isSessionStarted()) { + // only write/close session if the session was actually started by us + // otherwise we will set the session values to base64 encoded and whoever the session started might not expect the values in that way + parent::writeClose(); + } } public static function isSessionStarted() diff --git a/core/bootstrap.php b/core/bootstrap.php index 57c3f95f8d..04d161a57b 100644 --- a/core/bootstrap.php +++ b/core/bootstrap.php @@ -29,7 +29,9 @@ if (!defined('PIWIK_VENDOR_PATH')) { // NOTE: the code above must be PHP 4 compatible require_once PIWIK_INCLUDE_PATH . '/core/testMinimumPhpVersion.php'; -session_cache_limiter('nocache'); +if (session_status() !== PHP_SESSION_ACTIVE) { + session_cache_limiter('nocache'); +} define('PIWIK_DEFAULT_TIMEZONE', @date_default_timezone_get()); @date_default_timezone_set('UTC'); |