From 38ceb9275cbf4aee8b7d13bbbe1153976fa097b1 Mon Sep 17 00:00:00 2001 From: Mark Friedrich Date: Fri, 22 Jun 2018 19:59:35 +0200 Subject: [PATCH] - fixed init session _race condition_ on MySQL session setup, where `sessions` table is not already setup _before_ storing session data, #595 --- app/main/controller/controller.php | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/app/main/controller/controller.php b/app/main/controller/controller.php index 6d1e029a..acfb5e76 100644 --- a/app/main/controller/controller.php +++ b/app/main/controller/controller.php @@ -112,7 +112,6 @@ class Controller { * @param \Base $f3 */ protected function initSession(\Base $f3){ - $sessionCacheKey = $f3->get('SESSION_CACHE'); $session = null; /** @@ -135,10 +134,13 @@ class Controller { }; if( - $sessionCacheKey === 'mysql' && + $f3->get('SESSION_CACHE') === 'mysql' && $this->getDB('PF') instanceof DB\SQL ){ - $session = new DB\SQL\Session($this->getDB('PF'), 'sessions', true, $onSuspect); + + if(!headers_sent() && session_status()!=PHP_SESSION_ACTIVE){ + $session = new DB\SQL\Session($this->getDB('PF'), 'sessions', true, $onSuspect); + } } }