Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/matomo-org/matomo.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStefan Giehl <stefan@matomo.org>2021-07-13 11:21:51 +0300
committerGitHub <noreply@github.com>2021-07-13 11:21:51 +0300
commitfa66bc580852c2b098ba5ea7f7ba57048f258714 (patch)
treec853dcd88d842418a1ace4bddfa5842bbc10e502
parentbefedffaa6b5f28b6d6f804a7355b7078f7efc30 (diff)
Fix possible warning that session is not active for anonymous user (#17758)
* Fix possible warning that session is not active for anonymous user * update test
-rw-r--r--core/FrontController.php3
-rw-r--r--tests/PHPUnit/Integration/FrontControllerTest.php2
2 files changed, 3 insertions, 2 deletions
diff --git a/core/FrontController.php b/core/FrontController.php
index 359df2fa99..3928587017 100644
--- a/core/FrontController.php
+++ b/core/FrontController.php
@@ -409,7 +409,8 @@ class FrontController extends Singleton
&& Piwik::isUserIsAnonymous()
&& $authAdapter->getLogin() === 'anonymous' //double checking the login
&& Piwik::isUserHasSomeViewAccess()
- && Session::isSessionStarted()) { // only if session was started, don't do it eg for API
+ && Session::isSessionStarted()
+ && Session::isWritable()) { // only if session was started and writable, don't do it eg for API
// usually the session would be started when someone logs in using login controller. But in this
// case we need to init session here for anoynymous users
$init = StaticContainer::get(SessionInitializer::class);
diff --git a/tests/PHPUnit/Integration/FrontControllerTest.php b/tests/PHPUnit/Integration/FrontControllerTest.php
index f8593e8495..0d2f3c82b6 100644
--- a/tests/PHPUnit/Integration/FrontControllerTest.php
+++ b/tests/PHPUnit/Integration/FrontControllerTest.php
@@ -48,7 +48,7 @@ FORMAT;
$this->assertEquals('error', $response['result']);
$expectedFormat = <<<FORMAT
-test message on {includePath}/tests/resources/trigger-fatal-exception.php(23) #0 [internal function]: {closure}('CoreHome', 'index', Array) #1 {includePath}/core/EventDispatcher.php(141): call_user_func_array(Object(Closure), Array) #2 {includePath}/core/Piwik.php(809): Piwik\EventDispatcher-&gt;postEvent('Request.dispatc...', Array, false, Array) #3 {includePath}/core/FrontController.php(595): Piwik\Piwik::postEvent('Request.dispatc...', Array) #4 {includePath}/core/FrontController.php(167): Piwik\FrontController-&gt;doDispatch('CoreHome', 'index', Array) #5 {includePath}/tests/resources/trigger-fatal-exception.php(31): Piwik\FrontController-&gt;dispatch('CoreHome', 'index') #6 {main}
+test message on {includePath}/tests/resources/trigger-fatal-exception.php(23) #0 [internal function]: {closure}('CoreHome', 'index', Array) #1 {includePath}/core/EventDispatcher.php(141): call_user_func_array(Object(Closure), Array) #2 {includePath}/core/Piwik.php(809): Piwik\EventDispatcher-&gt;postEvent('Request.dispatc...', Array, false, Array) #3 {includePath}/core/FrontController.php(596): Piwik\Piwik::postEvent('Request.dispatc...', Array) #4 {includePath}/core/FrontController.php(167): Piwik\FrontController-&gt;doDispatch('CoreHome', 'index', Array) #5 {includePath}/tests/resources/trigger-fatal-exception.php(31): Piwik\FrontController-&gt;dispatch('CoreHome', 'index') #6 {main}
FORMAT;
$this->assertStringMatchesFormat($expectedFormat, $response['message']);
}