Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 029fb2e

Browse filesBrowse files
committed
bug #30620 [FrameworkBundle][HttpFoundation] make session service resettable (dmaicher)
This PR was merged into the 3.4 branch. Discussion ---------- [FrameworkBundle][HttpFoundation] make session service resettable | Q | A | ------------- | --- | Branch? | 3.4 | Bug fix? | yes | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | #30619 | License | MIT | Doc PR | - This fixes #30619 by making the session service "resettable" via `ServicesResetter`. Commits ------- e46ef76 [FrameworkBundle][HttpFoundation] make session service resettable
2 parents 9dad29d + e46ef76 commit 029fb2e
Copy full SHA for 029fb2e

File tree

Expand file treeCollapse file tree

4 files changed

+15
-2
lines changed
Filter options
Expand file treeCollapse file tree

4 files changed

+15
-2
lines changed

‎src/Symfony/Bundle/FrameworkBundle/Resources/config/session.xml

Copy file name to clipboardExpand all lines: src/Symfony/Bundle/FrameworkBundle/Resources/config/session.xml
+1Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
<argument type="service" id="session.storage" />
1616
<argument type="service" id="session.attribute_bag" />
1717
<argument type="service" id="session.flash_bag" />
18+
<tag name="kernel.reset" method="save" />
1819
</service>
1920

2021
<service id="Symfony\Component\HttpFoundation\Session\SessionInterface" alias="session" />

‎src/Symfony/Bundle/FrameworkBundle/composer.json

Copy file name to clipboardExpand all lines: src/Symfony/Bundle/FrameworkBundle/composer.json
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
"symfony/dependency-injection": "^3.4.24|^4.2.5",
2424
"symfony/config": "~3.4|~4.0",
2525
"symfony/event-dispatcher": "~3.4|~4.0",
26-
"symfony/http-foundation": "^3.3.11|~4.0",
26+
"symfony/http-foundation": "^3.4.24|^4.2.5",
2727
"symfony/http-kernel": "~3.4|~4.0",
2828
"symfony/polyfill-mbstring": "~1.0",
2929
"symfony/filesystem": "~2.8|~3.0|~4.0",

‎src/Symfony/Component/HttpFoundation/Session/Session.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/HttpFoundation/Session/Session.php
+3-1Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,9 @@ public function migrate($destroy = false, $lifetime = null)
193193
*/
194194
public function save()
195195
{
196-
$this->storage->save();
196+
if ($this->isStarted()) {
197+
$this->storage->save();
198+
}
197199
}
198200

199201
/**

‎src/Symfony/Component/HttpFoundation/Tests/Session/SessionTest.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/HttpFoundation/Tests/Session/SessionTest.php
+10Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -260,4 +260,14 @@ public function testIsEmpty()
260260
$flash->get('hello');
261261
$this->assertTrue($this->session->isEmpty());
262262
}
263+
264+
public function testSaveIfNotStarted()
265+
{
266+
$storage = $this->getMockBuilder('Symfony\Component\HttpFoundation\Session\Storage\SessionStorageInterface')->getMock();
267+
$session = new Session($storage);
268+
269+
$storage->expects($this->once())->method('isStarted')->willReturn(false);
270+
$storage->expects($this->never())->method('save');
271+
$session->save();
272+
}
263273
}

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.