From ac17fc8efd43b025c60ae0802c5bfacf5ca69a0d Mon Sep 17 00:00:00 2001 From: Matias Griese Date: Thu, 30 Jan 2020 23:32:17 +0200 Subject: [PATCH] Minor code cleanup --- system/src/Grav/Common/Processors/InitializeProcessor.php | 8 ++++++-- system/src/Grav/Common/Service/SessionServiceProvider.php | 2 +- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/system/src/Grav/Common/Processors/InitializeProcessor.php b/system/src/Grav/Common/Processors/InitializeProcessor.php index 8f119b997..fda562124 100644 --- a/system/src/Grav/Common/Processors/InitializeProcessor.php +++ b/system/src/Grav/Common/Processors/InitializeProcessor.php @@ -18,6 +18,7 @@ use Grav\Common\Utils; use Grav\Events\PluginsLoadedEvent; use Grav\Framework\Psr7\Response; use Grav\Framework\Session\Exceptions\SessionException; +use Grav\Framework\Session\SessionInterface; use Monolog\Formatter\LineFormatter; use Monolog\Handler\SyslogHandler; use Psr\Http\Message\ResponseInterface; @@ -215,10 +216,13 @@ class InitializeProcessor extends ProcessorBase // TODO: remove in 2.0. $this->container['accounts']; + /** @var SessionInterface $session */ + $session = $this->container['session']; + try { - $this->container['session']->init(); + $session->init(); } catch (SessionException $e) { - $this->container['session']->init(); + $session->init(); $message = 'Session corruption detected, restarting session...'; $this->addMessage($message); $this->container['messages']->add($message, 'error'); diff --git a/system/src/Grav/Common/Service/SessionServiceProvider.php b/system/src/Grav/Common/Service/SessionServiceProvider.php index 3acd66d0c..3e3268fa9 100644 --- a/system/src/Grav/Common/Service/SessionServiceProvider.php +++ b/system/src/Grav/Common/Service/SessionServiceProvider.php @@ -23,7 +23,7 @@ class SessionServiceProvider implements ServiceProviderInterface public function register(Container $container) { // Define session service. - $container['session'] = function ($c) { + $container['session'] = static function ($c) { /** @var Config $config */ $config = $c['config'];