diff --git a/CHANGELOG.md b/CHANGELOG.md index b55f80c01..b8880db35 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,9 @@ * Added new `Grav\Framework\File\Formatter` classes for encoding/decoding YAML, Markdown, JSON, INI and PHP serialized strings * Added `Grav\Common\Media` interfaces and trait; use those in `Page` and `Media` classes * Added `Grav\Common\Page` interface to allow custom page types in the future + * Added `Grav\Framework\Session` class to replace `RocketTheme\Toolbox\Session\Session` +1. [](#improved) + * Improved session handling, allow all session configuration options in `system.session.options` 1. [](#bugfix) * Fixed bug in `ContentBlock` serialization * Fixed `Route::withQueryParam()` to accept array values diff --git a/system/src/Grav/Framework/Session/Session.php b/system/src/Grav/Framework/Session/Session.php index ac6b96b61..db359342f 100644 --- a/system/src/Grav/Framework/Session/Session.php +++ b/system/src/Grav/Framework/Session/Session.php @@ -32,7 +32,7 @@ class Session implements \IteratorAggregate */ public static function instance() { - if (!isset(self::$instance)) { + if (null === self::$instance) { throw new \RuntimeException("Session hasn't been initialized.", 500); } @@ -46,14 +46,14 @@ public static function instance() public function __construct(array $options = []) { // Session is a singleton. - if (php_sapi_name() === 'cli') { + if (\PHP_SAPI === 'cli') { self::$instance = $this; return; } - if (isset(self::$instance)) { - throw new \RuntimeException("Session has already been initialized.", 500); + if (null !== self::$instance) { + throw new \RuntimeException('Session has already been initialized.', 500); } // Destroy any existing sessions started with session.auto_start @@ -147,6 +147,7 @@ public function setOptions(array $options) /** * Starts the session storage * + * @param bool $readonly * @return $this * @throws \RuntimeException */ @@ -357,7 +358,7 @@ public function started() */ protected function isSessionStarted() { - return php_sapi_name() !== 'cli' ? \PHP_SESSION_ACTIVE === session_status() : false; + return \PHP_SAPI !== 'cli' ? \PHP_SESSION_ACTIVE === session_status() : false; } /**