Update Composer packages
This commit is contained in:
parent
0320235f6c
commit
a8b68fb61b
378 changed files with 28466 additions and 28852 deletions
|
@ -75,11 +75,10 @@ class AutoSession
|
|||
}
|
||||
|
||||
// get the current session
|
||||
if ($options['detect'] === true) {
|
||||
$session = $this->sessions->currentDetected();
|
||||
} else {
|
||||
$session = $this->sessions->current();
|
||||
}
|
||||
$session = match ($options['detect']) {
|
||||
true => $this->sessions->currentDetected(),
|
||||
default => $this->sessions->current()
|
||||
};
|
||||
|
||||
// create a new session
|
||||
if ($session === null) {
|
||||
|
|
|
@ -157,7 +157,9 @@ class FileSessionStore extends SessionStore
|
|||
// check if the file is already unlocked or doesn't exist
|
||||
if (!isset($this->isLocked[$name])) {
|
||||
return;
|
||||
} elseif ($this->exists($expiryTime, $id) === false) {
|
||||
}
|
||||
|
||||
if ($this->exists($expiryTime, $id) === false) {
|
||||
unset($this->isLocked[$name]);
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -139,12 +139,12 @@ class Session
|
|||
if ($this->tokenExpiry !== null) {
|
||||
if (is_string($this->tokenKey)) {
|
||||
return $this->tokenExpiry . '.' . $this->tokenId . '.' . $this->tokenKey;
|
||||
} else {
|
||||
return $this->tokenExpiry . '.' . $this->tokenId;
|
||||
}
|
||||
} else {
|
||||
return null;
|
||||
|
||||
return $this->tokenExpiry . '.' . $this->tokenId;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -611,12 +611,15 @@ class Session
|
|||
// now make sure that we have a valid timestamp
|
||||
if (is_int($time)) {
|
||||
return $time;
|
||||
} else {
|
||||
throw new InvalidArgumentException([
|
||||
'data' => ['method' => 'Session::timeToTimestamp', 'argument' => '$time'],
|
||||
'translate' => false
|
||||
]);
|
||||
}
|
||||
|
||||
throw new InvalidArgumentException([
|
||||
'data' => [
|
||||
'method' => 'Session::timeToTimestamp',
|
||||
'argument' => '$time'
|
||||
],
|
||||
'translate' => false
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -727,7 +730,7 @@ class Session
|
|||
$this->renewable = $data['renewable'];
|
||||
|
||||
// reload data into existing object to avoid breaking memory references
|
||||
if (is_a($this->data, 'Kirby\Session\SessionData')) {
|
||||
if ($this->data instanceof SessionData) {
|
||||
$this->data()->reload($data['data']);
|
||||
} else {
|
||||
$this->data = new SessionData($this, $data['data']);
|
||||
|
|
|
@ -177,14 +177,19 @@ class SessionData
|
|||
{
|
||||
if (is_string($key)) {
|
||||
return $this->data[$key] ?? $default;
|
||||
} elseif ($key === null) {
|
||||
return $this->data;
|
||||
} else {
|
||||
throw new InvalidArgumentException([
|
||||
'data' => ['method' => 'SessionData::get', 'argument' => 'key'],
|
||||
'translate' => false
|
||||
]);
|
||||
}
|
||||
|
||||
if ($key === null) {
|
||||
return $this->data;
|
||||
}
|
||||
|
||||
throw new InvalidArgumentException([
|
||||
'data' => [
|
||||
'method' => 'SessionData::get',
|
||||
'argument' => 'key'
|
||||
],
|
||||
'translate' => false
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -40,7 +40,7 @@ class Sessions
|
|||
{
|
||||
if (is_string($store)) {
|
||||
$this->store = new FileSessionStore($store);
|
||||
} elseif (is_a($store, 'Kirby\Session\SessionStore') === true) {
|
||||
} elseif ($store instanceof SessionStore) {
|
||||
$this->store = $store;
|
||||
} else {
|
||||
throw new InvalidArgumentException([
|
||||
|
@ -101,9 +101,7 @@ class Sessions
|
|||
public function create(array $options = [])
|
||||
{
|
||||
// fall back to default mode
|
||||
if (!isset($options['mode'])) {
|
||||
$options['mode'] = $this->mode;
|
||||
}
|
||||
$options['mode'] ??= $this->mode;
|
||||
|
||||
return new Session($this, null, $options);
|
||||
}
|
||||
|
@ -117,11 +115,7 @@ class Sessions
|
|||
*/
|
||||
public function get(string $token, string $mode = null)
|
||||
{
|
||||
if (isset($this->cache[$token])) {
|
||||
return $this->cache[$token];
|
||||
}
|
||||
|
||||
return $this->cache[$token] = new Session($this, $token, ['mode' => $mode ?? $this->mode]);
|
||||
return $this->cache[$token] ??= new Session($this, $token, ['mode' => $mode ?? $this->mode]);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -131,38 +125,33 @@ class Sessions
|
|||
* - In `manual` mode: Fails and throws an Exception
|
||||
*
|
||||
* @return \Kirby\Session\Session|null Either the current session or null in case there isn't one
|
||||
* @throws \Kirby\Exception\Exception
|
||||
* @throws \Kirby\Exception\LogicException
|
||||
*/
|
||||
public function current()
|
||||
{
|
||||
$token = null;
|
||||
switch ($this->mode) {
|
||||
case 'cookie':
|
||||
$token = $this->tokenFromCookie();
|
||||
break;
|
||||
case 'header':
|
||||
$token = $this->tokenFromHeader();
|
||||
break;
|
||||
case 'manual':
|
||||
throw new LogicException([
|
||||
'key' => 'session.sessions.manualMode',
|
||||
'fallback' => 'Cannot automatically get current session in manual mode',
|
||||
'translate' => false,
|
||||
'httpCode' => 500
|
||||
]);
|
||||
default:
|
||||
// unexpected error that shouldn't occur
|
||||
throw new Exception(['translate' => false]); // @codeCoverageIgnore
|
||||
}
|
||||
$token = match ($this->mode) {
|
||||
'cookie' => $this->tokenFromCookie(),
|
||||
'header' => $this->tokenFromHeader(),
|
||||
'manual' => throw new LogicException([
|
||||
'key' => 'session.sessions.manualMode',
|
||||
'fallback' => 'Cannot automatically get current session in manual mode',
|
||||
'translate' => false,
|
||||
'httpCode' => 500
|
||||
]),
|
||||
// unexpected error that shouldn't occur
|
||||
default => throw new Exception(['translate' => false]) // @codeCoverageIgnore
|
||||
};
|
||||
|
||||
// no token was found, no session
|
||||
if (!is_string($token)) {
|
||||
if (is_string($token) === false) {
|
||||
return null;
|
||||
}
|
||||
|
||||
// token was found, try to get the session
|
||||
try {
|
||||
return $this->get($token);
|
||||
} catch (Throwable $e) {
|
||||
} catch (Throwable) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
@ -192,7 +181,7 @@ class Sessions
|
|||
try {
|
||||
$mode = (is_string($tokenFromHeader)) ? 'header' : 'cookie';
|
||||
return $this->get($token, $mode);
|
||||
} catch (Throwable $e) {
|
||||
} catch (Throwable) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
@ -253,11 +242,11 @@ class Sessions
|
|||
{
|
||||
$value = Cookie::get($this->cookieName());
|
||||
|
||||
if (is_string($value)) {
|
||||
return $value;
|
||||
} else {
|
||||
if (is_string($value) === false) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return $value;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -271,7 +260,7 @@ class Sessions
|
|||
$headers = $request->headers();
|
||||
|
||||
// check if the header exists at all
|
||||
if (!isset($headers['Authorization'])) {
|
||||
if (isset($headers['Authorization']) === false) {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue