|
|
@@ -19,6 +19,7 @@ declare(strict_types=1);
|
|
|
namespace Cake\Http\Session;
|
|
|
|
|
|
use Cake\ORM\Locator\LocatorAwareTrait;
|
|
|
+use ReturnTypeWillChange;
|
|
|
use SessionHandlerInterface;
|
|
|
|
|
|
/**
|
|
|
@@ -84,11 +85,11 @@ class DatabaseSession implements SessionHandlerInterface
|
|
|
/**
|
|
|
* Method called on open of a database session.
|
|
|
*
|
|
|
- * @param string $savePath The path where to store/retrieve the session.
|
|
|
+ * @param string $path The path where to store/retrieve the session.
|
|
|
* @param string $name The session name.
|
|
|
* @return bool Success
|
|
|
*/
|
|
|
- public function open($savePath, $name): bool
|
|
|
+ public function open($path, $name): bool
|
|
|
{
|
|
|
return true;
|
|
|
}
|
|
|
@@ -107,9 +108,10 @@ class DatabaseSession implements SessionHandlerInterface
|
|
|
* Method used to read from a database session.
|
|
|
*
|
|
|
* @param string $id ID that uniquely identifies session in database.
|
|
|
- * @return string Session data or empty string if it does not exist.
|
|
|
+ * @return string|false Session data or false if it does not exist.
|
|
|
*/
|
|
|
- public function read($id): string
|
|
|
+ #[ReturnTypeWillChange]
|
|
|
+ public function read($id)
|
|
|
{
|
|
|
/** @var string $pkField */
|
|
|
$pkField = $this->_table->getPrimaryKey();
|
|
|
@@ -121,20 +123,14 @@ class DatabaseSession implements SessionHandlerInterface
|
|
|
->first();
|
|
|
|
|
|
if (empty($result)) {
|
|
|
- return '';
|
|
|
+ return false;
|
|
|
}
|
|
|
|
|
|
if (is_string($result['data'])) {
|
|
|
return $result['data'];
|
|
|
}
|
|
|
|
|
|
- $session = stream_get_contents($result['data']);
|
|
|
-
|
|
|
- if ($session === false) {
|
|
|
- return '';
|
|
|
- }
|
|
|
-
|
|
|
- return $session;
|
|
|
+ return stream_get_contents($result['data']);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
@@ -180,12 +176,11 @@ class DatabaseSession implements SessionHandlerInterface
|
|
|
* Helper function called on gc for database sessions.
|
|
|
*
|
|
|
* @param int $maxlifetime Sessions that have not updated for the last maxlifetime seconds will be removed.
|
|
|
- * @return bool True on success, false on failure.
|
|
|
+ * @return int|false The number of deleted sessions on success, or false on failure.
|
|
|
*/
|
|
|
- public function gc($maxlifetime): bool
|
|
|
+ #[ReturnTypeWillChange]
|
|
|
+ public function gc($maxlifetime)
|
|
|
{
|
|
|
- $this->_table->deleteAll(['expires <' => time()]);
|
|
|
-
|
|
|
- return true;
|
|
|
+ return $this->_table->deleteAll(['expires <' => time()]);
|
|
|
}
|
|
|
}
|