Skip to content
Snippets Groups Projects
Commit 485e4942 authored by catch's avatar catch
Browse files

Issue #3377256 by elber, znerol, smustgrave, longwave, jungle, andypost:...

Issue #3377256 by elber, znerol, smustgrave, longwave, jungle, andypost: Correctly implement SessionHandlerInterface
parent 14167858
No related branches found
No related tags found
No related merge requests found
...@@ -46,7 +46,7 @@ public function __construct(RequestStack $request_stack, Connection $connection) ...@@ -46,7 +46,7 @@ public function __construct(RequestStack $request_stack, Connection $connection)
* {@inheritdoc} * {@inheritdoc}
*/ */
#[\ReturnTypeWillChange] #[\ReturnTypeWillChange]
public function open($save_path, $name) { public function open(string $save_path, string $name) {
return TRUE; return TRUE;
} }
...@@ -54,7 +54,7 @@ public function open($save_path, $name) { ...@@ -54,7 +54,7 @@ public function open($save_path, $name) {
* {@inheritdoc} * {@inheritdoc}
*/ */
#[\ReturnTypeWillChange] #[\ReturnTypeWillChange]
public function read(#[\SensitiveParameter] $sid) { public function read(#[\SensitiveParameter] string $sid) {
$data = ''; $data = '';
if (!empty($sid)) { if (!empty($sid)) {
// Read the session data from the database. // Read the session data from the database.
...@@ -69,7 +69,7 @@ public function read(#[\SensitiveParameter] $sid) { ...@@ -69,7 +69,7 @@ public function read(#[\SensitiveParameter] $sid) {
* {@inheritdoc} * {@inheritdoc}
*/ */
#[\ReturnTypeWillChange] #[\ReturnTypeWillChange]
public function write(#[\SensitiveParameter] $sid, $value) { public function write(#[\SensitiveParameter] string $sid, $value) {
$request = $this->requestStack->getCurrentRequest(); $request = $this->requestStack->getCurrentRequest();
$fields = [ $fields = [
'uid' => $request->getSession()->get('uid', 0), 'uid' => $request->getSession()->get('uid', 0),
...@@ -96,7 +96,7 @@ public function close() { ...@@ -96,7 +96,7 @@ public function close() {
* {@inheritdoc} * {@inheritdoc}
*/ */
#[\ReturnTypeWillChange] #[\ReturnTypeWillChange]
public function destroy(#[\SensitiveParameter] $sid) { public function destroy(#[\SensitiveParameter] string $sid) {
// Delete session data. // Delete session data.
$this->connection->delete('sessions') $this->connection->delete('sessions')
->condition('sid', Crypt::hashBase64($sid)) ->condition('sid', Crypt::hashBase64($sid))
...@@ -109,16 +109,15 @@ public function destroy(#[\SensitiveParameter] $sid) { ...@@ -109,16 +109,15 @@ public function destroy(#[\SensitiveParameter] $sid) {
* {@inheritdoc} * {@inheritdoc}
*/ */
#[\ReturnTypeWillChange] #[\ReturnTypeWillChange]
public function gc($lifetime) { public function gc(int $lifetime) {
// Be sure to adjust 'php_value session.gc_maxlifetime' to a large enough // Be sure to adjust 'php_value session.gc_maxlifetime' to a large enough
// value. For example, if you want user sessions to stay in your database // value. For example, if you want user sessions to stay in your database
// for three weeks before deleting them, you need to set gc_maxlifetime // for three weeks before deleting them, you need to set gc_maxlifetime
// to '1814400'. At that value, only after a user doesn't log in after // to '1814400'. At that value, only after a user doesn't log in after
// three weeks (1814400 seconds) will their session be removed. // three weeks (1814400 seconds) will their session be removed.
$this->connection->delete('sessions') return $this->connection->delete('sessions')
->condition('timestamp', REQUEST_TIME - $lifetime, '<') ->condition('timestamp', REQUEST_TIME - $lifetime, '<')
->execute(); ->execute();
return TRUE;
} }
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment