Skip to content

Commit 2583c26

Browse files
author
Drak
committed
[HttpFoundation][FrameworkBundle] Keep save auto_start behaviour as in 2.2 and make component values consistent with FrameworkBundle's configuration options.
1 parent ceaf69b commit 2583c26

File tree

5 files changed

+15
-27
lines changed

5 files changed

+15
-27
lines changed

src/Symfony/Bundle/FrameworkBundle/CHANGELOG.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,7 @@ CHANGELOG
99
* added `TimedPhpEngine`
1010
* added `--clean` option the the `translation:update` command
1111
* added `http_method_override` option
12-
* Reintroduce `auto_start` session config flag which control to `SessionListener` to manually start sessions
13-
during framework request cycle.
12+
* Reintroduce `auto_start` session config flag to instruct the `SessionListener` to manually start session
1413
* Added session config option `on_demand_mode` to control session start on demand.
1514

1615
2.2.0

src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Configuration.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,7 @@ private function addSessionSection(ArrayNodeDefinition $rootNode)
185185
->canBeUnset()
186186
->children()
187187
->booleanNode('auto_start')
188-
->defaultTrue()
188+
->defaultFalse()
189189
->info('Flag for SessionListener to start session')
190190
->end()
191191
->enumNode('on_demand_mode')

src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -319,18 +319,7 @@ private function registerSessionConfiguration(array $config, ContainerBuilder $c
319319
$container->setParameter('session.auto_start', $config['auto_start']);
320320

321321
// this controls the session start on demand feature
322-
switch ($config['on_demand_mode']) {
323-
// already validated
324-
case 'on':
325-
$demand = SessionStorageInterface::START_ON_DEMAND;
326-
break;
327-
case 'off':
328-
$demand = SessionStorageInterface::NO_START_ON_DEMAND_STRICT;
329-
break;
330-
case 'off_lax':
331-
$demand = SessionStorageInterface::NO_START_ON_DEMAND_LAX;
332-
}
333-
$container->setParameter('session.storage.on_demand_mode', $demand);
322+
$container->setParameter('session.storage.on_demand_mode', $config['on_demand_mode']);
334323

335324
$container->setParameter('session.storage.mock_name', $config['mock_name']);
336325

src/Symfony/Bundle/FrameworkBundle/EventListener/SessionListener.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ class SessionListener implements EventSubscriberInterface
3131
private $container;
3232
private $autoStart;
3333

34-
public function __construct(ContainerInterface $container, $autoStart)
34+
public function __construct(ContainerInterface $container, $autoStart = false)
3535
{
3636
$this->container = $container;
3737
$this->autoStart = $autoStart;

src/Symfony/Component/HttpFoundation/Session/Storage/SessionStorageInterface.php

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -28,24 +28,24 @@ interface SessionStorageInterface
2828
* Do not start session on demand and throw exception if attempt
2929
* is make to read or write bag data.
3030
*/
31-
const NO_START_ON_DEMAND_STRICT = 0;
31+
const NO_START_ON_DEMAND_STRICT = 'off';
3232

3333
/**
3434
* Start the session on demand when accessing bag data.
3535
*/
36-
const START_ON_DEMAND = 1;
36+
const START_ON_DEMAND = 'on';
3737

3838
/**
3939
* Do not start session on demand but allow access to session bags.
4040
*/
41-
const NO_START_ON_DEMAND_LAX = 2;
41+
const NO_START_ON_DEMAND_LAX = 'off_lax';
4242

4343
/**
4444
* Starts the session.
4545
*
46-
* @throws \RuntimeException If something goes wrong starting the session.
46+
* @throws \RuntimeException If something goes wrong starting the session
4747
*
48-
* @return boolean True if started.
48+
* @return boolean True if started
4949
*
5050
* @api
5151
*/
@@ -54,14 +54,14 @@ public function start();
5454
/**
5555
* Checks if the session is started.
5656
*
57-
* @return boolean True if started, false otherwise.
57+
* @return boolean True if started, false otherwise
5858
*/
5959
public function isStarted();
6060

6161
/**
6262
* Returns the session ID
6363
*
64-
* @return string The session ID or empty.
64+
* @return string The session ID or empty
6565
*
6666
* @api
6767
*/
@@ -79,7 +79,7 @@ public function setId($id);
7979
/**
8080
* Returns the session name
8181
*
82-
* @return mixed The session name.
82+
* @return mixed The session name
8383
*
8484
* @api
8585
*/
@@ -105,11 +105,11 @@ public function setName($name);
105105
* Note regenerate+destroy should not clear the session data in memory
106106
* only delete the session data from persistent storage.
107107
*
108-
* @param Boolean $destroy Destroy session when regenerating?
108+
* @param Boolean $destroy Flag true to destroy session when regenerating
109109
* @param integer $lifetime Sets the cookie lifetime for the session cookie. A null value
110110
* will leave the system settings unchanged, 0 sets the cookie
111111
* to expire with browser session. Time is in seconds, and is
112-
* not a Unix timestamp.
112+
* not a Unix timestamp
113113
*
114114
* @return Boolean True if session regenerated, false if error
115115
*
@@ -128,7 +128,7 @@ public function regenerate($destroy = false, $lifetime = null);
128128
* it should actually persist the session data if required.
129129
*
130130
* @throws \RuntimeException If the session is saved without being started, or if the session
131-
* is already closed.
131+
* is already closed
132132
*/
133133
public function save();
134134

0 commit comments

Comments
 (0)