mirror of
https://github.com/getgrav/grav.git
synced 2026-02-05 14:20:32 +01:00
Fixed session throwing error in CLI if initialized
This commit is contained in:
@@ -26,6 +26,7 @@
|
||||
* Fixed `Object` serialization breaking if overriding `jsonSerialize()` method
|
||||
* Grav 1.6: Fixed `FlexObject::update()` call with partial object update
|
||||
* Fixed `YamlFormatter::decode()` when calling `init_set()` with integer
|
||||
* Fixed session throwing error in CLI if initialized
|
||||
|
||||
# v1.6.0-beta.6
|
||||
## 11/12/2018
|
||||
|
||||
@@ -31,7 +31,7 @@ class Session extends \Grav\Framework\Session\Session
|
||||
*/
|
||||
public function init()
|
||||
{
|
||||
if ($this->autoStart) {
|
||||
if ($this->autoStart && !$this->isStarted()) {
|
||||
$this->start();
|
||||
|
||||
$this->autoStart = false;
|
||||
|
||||
@@ -175,6 +175,10 @@ class Session implements SessionInterface
|
||||
*/
|
||||
public function start($readonly = false)
|
||||
{
|
||||
if (\PHP_SAPI === 'cli') {
|
||||
return $this;
|
||||
}
|
||||
|
||||
// Protection against invalid session cookie names throwing exception: http://php.net/manual/en/function.session-id.php#116836
|
||||
if (isset($_COOKIE[session_name()]) && !preg_match('/^[-,a-zA-Z0-9]{1,128}$/', $_COOKIE[session_name()])) {
|
||||
unset($_COOKIE[session_name()]);
|
||||
@@ -189,6 +193,7 @@ class Session implements SessionInterface
|
||||
if (!$success) {
|
||||
$last = error_get_last();
|
||||
$error = $last ? $last['message'] : 'Unknown error';
|
||||
debug_print_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS);die();
|
||||
throw new \RuntimeException('Failed to start session: ' . $error, 500);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user