From 9162f714e0dd05ed7a425bbf75c6a6b8aa21a9df Mon Sep 17 00:00:00 2001 From: Hypolite Petovan Date: Thu, 11 Apr 2019 05:26:37 -0400 Subject: [PATCH 1/2] Add uri to missing session data logging context in Session handlers --- src/Core/Session/CacheSessionHandler.php | 4 +++- src/Core/Session/DatabaseSessionHandler.php | 3 ++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src/Core/Session/CacheSessionHandler.php b/src/Core/Session/CacheSessionHandler.php index c0a5896f4..6a1b32bfb 100644 --- a/src/Core/Session/CacheSessionHandler.php +++ b/src/Core/Session/CacheSessionHandler.php @@ -31,7 +31,9 @@ class CacheSessionHandler extends BaseObject implements SessionHandlerInterface Session::$exists = true; return $data; } - Logger::log("no data for session $session_id", Logger::TRACE); + + Logger::notice('no data for session', ['session_id' => $session_id, 'uri' => $_SERVER['REQUEST_URI']]); + return ''; } diff --git a/src/Core/Session/DatabaseSessionHandler.php b/src/Core/Session/DatabaseSessionHandler.php index 9bb1180ec..e3e95f9ed 100644 --- a/src/Core/Session/DatabaseSessionHandler.php +++ b/src/Core/Session/DatabaseSessionHandler.php @@ -31,7 +31,8 @@ class DatabaseSessionHandler extends BaseObject implements SessionHandlerInterfa Session::$exists = true; return $session['data']; } - Logger::log("no data for session $session_id", Logger::TRACE); + + Logger::notice('no data for session', ['session_id' => $session_id, 'uri' => $_SERVER['REQUEST_URI']]); return ''; } From 900074d11797c0387249796d4d5cbbbe4c372445 Mon Sep 17 00:00:00 2001 From: Hypolite Petovan Date: Thu, 11 Apr 2019 05:27:26 -0400 Subject: [PATCH 2/2] Move App->checkBackend after module determination - Update App->checkBackend to remove dependency to App properties --- src/App.php | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/App.php b/src/App.php index 21675b9dc..316982dd2 100644 --- a/src/App.php +++ b/src/App.php @@ -248,7 +248,6 @@ class App $this->profiler = $profiler; $this->logger = $logger; - $this->checkBackend($isBackend); $this->checkFriendicaApp(); $this->profiler->reset(); @@ -318,6 +317,8 @@ class App $this->module = 'home'; } + $this->isBackend = $isBackend || $this->checkBackend($this->module); + // Detect mobile devices $mobile_detect = new MobileDetect(); @@ -623,10 +624,10 @@ class App * This isn't a perfect solution. But we need this check very early. * So we cannot wait until the modules are loaded. * - * @param string $backend true, if the backend flag was set during App initialization - * + * @param string $module + * @return bool */ - private function checkBackend($backend) { + private function checkBackend($module) { static $backends = [ '_well_known', 'api', @@ -651,7 +652,7 @@ class App ]; // Check if current module is in backend or backend flag is set - $this->isBackend = (in_array($this->module, $backends) || $backend || $this->isBackend); + return in_array($module, $backends); } /**