From 2583c2614fafbaf567ae6c8123bef093a303cb2c Mon Sep 17 00:00:00 2001 From: Drak Date: Sat, 6 Apr 2013 17:57:34 +0100 Subject: [PATCH] [HttpFoundation][FrameworkBundle] Keep save auto_start behaviour as in 2.2 and make component values consistent with FrameworkBundle's configuration options. --- .../Bundle/FrameworkBundle/CHANGELOG.md | 3 +-- .../DependencyInjection/Configuration.php | 2 +- .../FrameworkExtension.php | 13 +---------- .../EventListener/SessionListener.php | 2 +- .../Storage/SessionStorageInterface.php | 22 +++++++++---------- 5 files changed, 15 insertions(+), 27 deletions(-) diff --git a/src/Symfony/Bundle/FrameworkBundle/CHANGELOG.md b/src/Symfony/Bundle/FrameworkBundle/CHANGELOG.md index ada613ef9b..feacfdb46f 100644 --- a/src/Symfony/Bundle/FrameworkBundle/CHANGELOG.md +++ b/src/Symfony/Bundle/FrameworkBundle/CHANGELOG.md @@ -9,8 +9,7 @@ CHANGELOG * added `TimedPhpEngine` * added `--clean` option the the `translation:update` command * added `http_method_override` option - * Reintroduce `auto_start` session config flag which control to `SessionListener` to manually start sessions - during framework request cycle. + * Reintroduce `auto_start` session config flag to instruct the `SessionListener` to manually start session * Added session config option `on_demand_mode` to control session start on demand. 2.2.0 diff --git a/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Configuration.php b/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Configuration.php index ffd05e426f..5bbbeab828 100644 --- a/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Configuration.php +++ b/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Configuration.php @@ -185,7 +185,7 @@ class Configuration implements ConfigurationInterface ->canBeUnset() ->children() ->booleanNode('auto_start') - ->defaultTrue() + ->defaultFalse() ->info('Flag for SessionListener to start session') ->end() ->enumNode('on_demand_mode') diff --git a/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php b/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php index 368b591b5e..2793aea372 100644 --- a/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php +++ b/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php @@ -319,18 +319,7 @@ class FrameworkExtension extends Extension $container->setParameter('session.auto_start', $config['auto_start']); // this controls the session start on demand feature - switch ($config['on_demand_mode']) { - // already validated - case 'on': - $demand = SessionStorageInterface::START_ON_DEMAND; - break; - case 'off': - $demand = SessionStorageInterface::NO_START_ON_DEMAND_STRICT; - break; - case 'off_lax': - $demand = SessionStorageInterface::NO_START_ON_DEMAND_LAX; - } - $container->setParameter('session.storage.on_demand_mode', $demand); + $container->setParameter('session.storage.on_demand_mode', $config['on_demand_mode']); $container->setParameter('session.storage.mock_name', $config['mock_name']); diff --git a/src/Symfony/Bundle/FrameworkBundle/EventListener/SessionListener.php b/src/Symfony/Bundle/FrameworkBundle/EventListener/SessionListener.php index 0977d8d8dc..f594a85ddd 100644 --- a/src/Symfony/Bundle/FrameworkBundle/EventListener/SessionListener.php +++ b/src/Symfony/Bundle/FrameworkBundle/EventListener/SessionListener.php @@ -31,7 +31,7 @@ class SessionListener implements EventSubscriberInterface private $container; private $autoStart; - public function __construct(ContainerInterface $container, $autoStart) + public function __construct(ContainerInterface $container, $autoStart = false) { $this->container = $container; $this->autoStart = $autoStart; diff --git a/src/Symfony/Component/HttpFoundation/Session/Storage/SessionStorageInterface.php b/src/Symfony/Component/HttpFoundation/Session/Storage/SessionStorageInterface.php index cfd785c663..691c27933a 100644 --- a/src/Symfony/Component/HttpFoundation/Session/Storage/SessionStorageInterface.php +++ b/src/Symfony/Component/HttpFoundation/Session/Storage/SessionStorageInterface.php @@ -28,24 +28,24 @@ interface SessionStorageInterface * Do not start session on demand and throw exception if attempt * is make to read or write bag data. */ - const NO_START_ON_DEMAND_STRICT = 0; + const NO_START_ON_DEMAND_STRICT = 'off'; /** * Start the session on demand when accessing bag data. */ - const START_ON_DEMAND = 1; + const START_ON_DEMAND = 'on'; /** * Do not start session on demand but allow access to session bags. */ - const NO_START_ON_DEMAND_LAX = 2; + const NO_START_ON_DEMAND_LAX = 'off_lax'; /** * Starts the session. * - * @throws \RuntimeException If something goes wrong starting the session. + * @throws \RuntimeException If something goes wrong starting the session * - * @return boolean True if started. + * @return boolean True if started * * @api */ @@ -54,14 +54,14 @@ interface SessionStorageInterface /** * Checks if the session is started. * - * @return boolean True if started, false otherwise. + * @return boolean True if started, false otherwise */ public function isStarted(); /** * Returns the session ID * - * @return string The session ID or empty. + * @return string The session ID or empty * * @api */ @@ -79,7 +79,7 @@ interface SessionStorageInterface /** * Returns the session name * - * @return mixed The session name. + * @return mixed The session name * * @api */ @@ -105,11 +105,11 @@ interface SessionStorageInterface * Note regenerate+destroy should not clear the session data in memory * only delete the session data from persistent storage. * - * @param Boolean $destroy Destroy session when regenerating? + * @param Boolean $destroy Flag true to destroy session when regenerating * @param integer $lifetime Sets the cookie lifetime for the session cookie. A null value * will leave the system settings unchanged, 0 sets the cookie * to expire with browser session. Time is in seconds, and is - * not a Unix timestamp. + * not a Unix timestamp * * @return Boolean True if session regenerated, false if error * @@ -128,7 +128,7 @@ interface SessionStorageInterface * it should actually persist the session data if required. * * @throws \RuntimeException If the session is saved without being started, or if the session - * is already closed. + * is already closed */ public function save();