Unverified Commit 9498875e authored by larowlan's avatar larowlan
Browse files

Issue #2961861 by alexpott, Berdir: Remove usage of WriteCheckSessionHandler

parent 4da678eb
......@@ -1549,10 +1549,6 @@ services:
arguments: ['@request_stack', '@database']
tags:
- { name: backend_overridable }
session_handler.write_check:
class: Symfony\Component\HttpFoundation\Session\Storage\Handler\WriteCheckSessionHandler
tags:
- { name: session_handler_proxy, priority: 100 }
session_handler.write_safe:
class: Drupal\Core\Session\WriteSafeSessionHandler
tags:
......
......@@ -3,7 +3,7 @@
namespace Drupal\Core\Session;
/**
* Wraps another SessionHandlerInterface to prevent writes when not allowed.
* Wraps the session handler to prevent writes when not necessary or allowed.
*/
class WriteSafeSessionHandler implements \SessionHandlerInterface, WriteSafeSessionHandlerInterface {
......@@ -19,6 +19,14 @@ class WriteSafeSessionHandler implements \SessionHandlerInterface, WriteSafeSess
*/
protected $sessionWritable;
/**
* The read sessions.
*
* @var array
* Session data keyed by the session ID.
*/
private $readSessions;
/**
* Constructs a new write safe session handler.
*
......@@ -64,19 +72,23 @@ public function open($save_path, $session_id) {
* {@inheritdoc}
*/
public function read($session_id) {
return $this->wrappedSessionHandler->read($session_id);
$value = $this->wrappedSessionHandler->read($session_id);
$this->readSessions[$session_id] = $value;
return $value;
}
/**
* {@inheritdoc}
*/
public function write($session_id, $session_data) {
// Only write the session when it has been modified.
if (isset($this->readSessions[$session_id]) && $this->readSessions[$session_id] === $session_data) {
return TRUE;
}
if ($this->isSessionWritable()) {
return $this->wrappedSessionHandler->write($session_id, $session_data);
}
else {
return TRUE;
}
return TRUE;
}
/**
......
......@@ -126,8 +126,6 @@ public static function getSkippedDeprecations() {
// is a Windows only deprecation. Remove when core no longer uses
// WinCacheClassLoader in \Drupal\Core\DrupalKernel::initializeSettings().
'The Symfony\Component\ClassLoader\WinCacheClassLoader class is deprecated since Symfony 3.3 and will be removed in 4.0. Use `composer install --apcu-autoloader` instead.',
'The Symfony\Component\HttpFoundation\Session\Storage\Handler\WriteCheckSessionHandler class is deprecated since Symfony 3.4 and will be removed in 4.0. Implement `SessionUpdateTimestampHandlerInterface` or extend `AbstractSessionHandler` instead.',
'The "session_handler.write_check" service relies on the deprecated "Symfony\Component\HttpFoundation\Session\Storage\Handler\WriteCheckSessionHandler" class. It should either be deprecated or its implementation upgraded.',
'Not setting the strict option of the Choice constraint to true is deprecated since Symfony 3.4 and will throw an exception in 4.0.',
];
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment