Skip to content
Snippets Groups Projects
Verified Commit 3d7ea45c authored by Lee Rowlands's avatar Lee Rowlands
Browse files

Issue #3045349 by alexpott, mikelutz, mglaman: Lazy started sessions with...

Issue #3045349 by alexpott, mikelutz, mglaman: Lazy started sessions with session data are not saved with symfony/http-foundation 3.4.24
parent bd59fbc6
No related branches found
No related tags found
No related merge requests found
...@@ -216,7 +216,9 @@ public function regenerate($destroy = FALSE, $lifetime = NULL) { ...@@ -216,7 +216,9 @@ public function regenerate($destroy = FALSE, $lifetime = NULL) {
throw new \InvalidArgumentException('The optional parameters $destroy and $lifetime of SessionManager::regenerate() are not supported currently'); throw new \InvalidArgumentException('The optional parameters $destroy and $lifetime of SessionManager::regenerate() are not supported currently');
} }
if ($this->isStarted()) { // Only migrate the session if the session is really started and not only
// lazy started.
if ($this->started) {
$old_session_id = $this->getId(); $old_session_id = $this->getId();
// Save and close the old session. Call the parent method to avoid issue // Save and close the old session. Call the parent method to avoid issue
// with session destruction due to the session being considered obsolete. // with session destruction due to the session being considered obsolete.
...@@ -340,4 +342,19 @@ protected function migrateStoredSession($old_session_id) { ...@@ -340,4 +342,19 @@ protected function migrateStoredSession($old_session_id) {
->execute(); ->execute();
} }
/**
* Checks if the session is started.
*
* Beginning with symfony/http-foundation 3.4.24, the session will no longer
* save unless this method returns true. The parent method returns true if
* $this->started is true, but we need the session to also save if we lazy
* started, so we override isStarted() here.
*
* @return bool
* True if started, false otherwise
*/
public function isStarted() {
return parent::isStarted() || $this->startedLazy;
}
} }
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