From e217489d37b917f9a7931fd551498cdd88eae9e5 Mon Sep 17 00:00:00 2001 From: Matias Griese Date: Wed, 27 Dec 2017 21:03:41 +0200 Subject: [PATCH] Added new configuration option `system.session.initialize` to delay session initialization if needed by a plugin --- CHANGELOG.md | 2 ++ system/config/system.yaml | 1 + system/src/Grav/Common/Processors/InitializeProcessor.php | 8 ++++++-- 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index a8d0d0b47..4cf6790e2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,8 @@ 1. [](#bugfix) * Fix for `vundefined` error for version numbers in GPM [form#222](https://github.com/getgrav/grav-plugin-form/issues/222) +1. [](#improved) + * Added new configuration option `system.session.initialize` to delay session initialization if needed by a plugin # v1.4.0-beta.2 ## 12/18/2017 diff --git a/system/config/system.yaml b/system/config/system.yaml index 72c6bc2ff..1416c92e2 100644 --- a/system/config/system.yaml +++ b/system/config/system.yaml @@ -132,6 +132,7 @@ media: session: enabled: true # Enable Session support + initialize: true # Initialize session from Grav (if false, plugin needs to start the session) timeout: 1800 # Timeout in seconds name: grav-site # Name prefix of the session cookie. Use alphanumeric, dashes or underscores only. Do not use dots in the session name secure: false # Set session secure. If true, indicates that communication for this cookie must be over an encrypted transmission. Enable this only on sites that run exclusively on HTTPS diff --git a/system/src/Grav/Common/Processors/InitializeProcessor.php b/system/src/Grav/Common/Processors/InitializeProcessor.php index 1b4022735..da4bcee08 100644 --- a/system/src/Grav/Common/Processors/InitializeProcessor.php +++ b/system/src/Grav/Common/Processors/InitializeProcessor.php @@ -31,8 +31,12 @@ class InitializeProcessor extends ProcessorBase implements ProcessorInterface date_default_timezone_set($this->container['config']->get('system.timezone')); } - // Initialize uri, session. - $this->container['session']->init(); + // FIXME: Initialize session should happen later after plugins have been loaded. This is a workaround to fix session issues in AWS. + if ($this->container['config']->get('system.session.initialize', 1)) { + $this->container['session']->init(); + } + + // Initialize uri. $this->container['uri']->init(); $this->container->setLocale();