Session.php (cakephp-4.2.2) | : | Session.php (cakephp-4.2.3) | ||
---|---|---|---|---|
skipping to change at line 434 | skipping to change at line 434 | |||
} | } | |||
return Hash::get($_SESSION, $name) !== null; | return Hash::get($_SESSION, $name) !== null; | |||
} | } | |||
/** | /** | |||
* Returns given session variable, or all of them, if no parameters given. | * Returns given session variable, or all of them, if no parameters given. | |||
* | * | |||
* @param string|null $name The name of the session variable (or a path as s ent to Hash.extract) | * @param string|null $name The name of the session variable (or a path as s ent to Hash.extract) | |||
* @param mixed $default The return value when the path does not exist | * @param mixed $default The return value when the path does not exist | |||
* @return mixed|null The value of the session variable, null if session not | * @return mixed|null The value of the session variable, or default value if | |||
available, | a session | |||
* session not started, or provided name not found in the session. | * is not available, can't be started, or provided $name is not found in t | |||
he session. | ||||
*/ | */ | |||
public function read(?string $name = null, $default = null) | public function read(?string $name = null, $default = null) | |||
{ | { | |||
if ($this->_hasSession() && !$this->started()) { | if ($this->_hasSession() && !$this->started()) { | |||
$this->start(); | $this->start(); | |||
} | } | |||
if (!isset($_SESSION)) { | if (!isset($_SESSION)) { | |||
return null; | return $default; | |||
} | } | |||
if ($name === null) { | if ($name === null) { | |||
return $_SESSION ?: []; | return $_SESSION ?: []; | |||
} | } | |||
return Hash::get($_SESSION, $name, $default); | return Hash::get($_SESSION, $name, $default); | |||
} | } | |||
/** | /** | |||
End of changes. 2 change blocks. | ||||
4 lines changed or deleted | 5 lines changed or added |