Skip to content

Commit 3deb394

Browse files
Alexandru FurculitaTobion
authored andcommitted
[HttpFoundation] Deprecate compatibility with PHP <5.4 sessions
1 parent f617882 commit 3deb394

23 files changed

+79
-90
lines changed

UPGRADE-3.4.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -205,6 +205,24 @@ FrameworkBundle
205205
`TranslationDebugCommand`, `TranslationUpdateCommand`, `XliffLintCommand`
206206
and `YamlLintCommand` classes have been marked as final
207207

208+
HttpFoundation
209+
--------------
210+
211+
* The `Symfony\Component\HttpFoundation\Session\Storage\Handler\NativeSessionHandler`
212+
class has been deprecated and will be removed in 4.0. Use the `\SessionHandler` class instead.
213+
214+
* The `Symfony\Component\HttpFoundation\Session\Storage\Proxy\AbstractProxy` class has been
215+
deprecated and will be removed in 4.0. Use your `\SessionHandlerInterface` implementation directly.
216+
217+
* The `Symfony\Component\HttpFoundation\Session\Storage\Proxy\NativeProxy` class has been
218+
deprecated and will be removed in 4.0. Use your `\SessionHandlerInterface` implementation directly.
219+
220+
* The `Symfony\Component\HttpFoundation\Session\Storage\Proxy\SessionHandlerProxy` class has been
221+
deprecated and will be removed in 4.0. Use your `\SessionHandlerInterface` implementation directly.
222+
223+
* `NativeSessionStorage::setSaveHandler()` now takes an instance of `\SessionHandlerInterface` as argument.
224+
Not passing it is deprecated and will throw a `TypeError` in 4.0.
225+
208226
HttpKernel
209227
----------
210228

UPGRADE-4.0.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -524,6 +524,13 @@ HttpFoundation
524524
* The ability to check only for cacheable HTTP methods using `Request::isMethodSafe()` is
525525
not supported anymore, use `Request::isMethodCacheable()` instead.
526526

527+
* The `Symfony\Component\HttpFoundation\Session\Storage\Handler\NativeSessionHandler`,
528+
`Symfony\Component\HttpFoundation\Session\Storage\Proxy\AbstractProxy`,
529+
`Symfony\Component\HttpFoundation\Session\Storage\Proxy\NativeProxy` and
530+
`Symfony\Component\HttpFoundation\Session\Storage\Proxy\SessionHandlerProxy` classes have been removed.
531+
532+
* `NativeSessionStorage::setSaveHandler()` now requires an instance of `\SessionHandlerInterface` as argument.
533+
527534
HttpKernel
528535
----------
529536

src/Symfony/Bridge/Twig/Tests/AppVariableTest.php

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,9 @@ public function testEnvironment()
4747

4848
public function testGetSession()
4949
{
50+
$session = $this->getMockBuilder(Session::class)->disableOriginalConstructor()->getMock();
5051
$request = $this->getMockBuilder('Symfony\Component\HttpFoundation\Request')->getMock();
51-
$request->method('getSession')->willReturn($session = new Session());
52+
$request->method('getSession')->willReturn($session);
5253

5354
$this->setRequestStack($request);
5455

@@ -167,8 +168,9 @@ public function testGetFlashesWithNoRequest()
167168

168169
public function testGetFlashesWithNoSessionStarted()
169170
{
171+
$session = $this->getMockBuilder(Session::class)->disableOriginalConstructor()->getMock();
170172
$request = $this->getMockBuilder('Symfony\Component\HttpFoundation\Request')->getMock();
171-
$request->method('getSession')->willReturn(new Session());
173+
$request->method('getSession')->willReturn($session);
172174

173175
$this->setRequestStack($request);
174176

@@ -257,7 +259,7 @@ private function setFlashMessages()
257259
$flashBag = new FlashBag();
258260
$flashBag->initialize($flashMessages);
259261

260-
$session = $this->getMockBuilder('Symfony\Component\HttpFoundation\Session\Session')->getMock();
262+
$session = $this->getMockBuilder('Symfony\Component\HttpFoundation\Session\Session')->disableOriginalConstructor()->getMock();
261263
$session->method('isStarted')->willReturn(true);
262264
$session->method('getFlashBag')->willReturn($flashBag);
263265

src/Symfony/Bundle/FrameworkBundle/Tests/Controller/ControllerTraitTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -376,7 +376,7 @@ public function testRedirectToRoute()
376376
public function testAddFlash()
377377
{
378378
$flashBag = new FlashBag();
379-
$session = $this->getMockBuilder('Symfony\Component\HttpFoundation\Session\Session')->getMock();
379+
$session = $this->getMockBuilder('Symfony\Component\HttpFoundation\Session\Session')->disableOriginalConstructor()->getMock();
380380
$session->expects($this->once())->method('getFlashBag')->willReturn($flashBag);
381381

382382
$container = new Container();

src/Symfony/Component/HttpFoundation/CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,13 @@
11
CHANGELOG
22
=========
33

4+
3.4.0
5+
-----
6+
7+
* deprecated the `NativeSessionHandler` class,
8+
* deprecated the `AbstractProxy`, `NativeProxy` and `SessionHandlerProxy` classes,
9+
* deprecated setting session save handlers that do not implement `\SessionHandlerInterface` in `NativeSessionStorage::setSaveHandler()`
10+
411
3.3.0
512
-----
613

src/Symfony/Component/HttpFoundation/Session/Storage/Handler/MemcacheSessionHandler.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,6 @@
1212
namespace Symfony\Component\HttpFoundation\Session\Storage\Handler;
1313

1414
/**
15-
* MemcacheSessionHandler.
16-
*
1715
* @author Drak <[email protected]>
1816
*/
1917
class MemcacheSessionHandler implements \SessionHandlerInterface

src/Symfony/Component/HttpFoundation/Session/Storage/Handler/MemcachedSessionHandler.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,6 @@
1212
namespace Symfony\Component\HttpFoundation\Session\Storage\Handler;
1313

1414
/**
15-
* MemcachedSessionHandler.
16-
*
1715
* Memcached based session storage handler based on the Memcached class
1816
* provided by the PHP memcached extension.
1917
*

src/Symfony/Component/HttpFoundation/Session/Storage/Handler/MongoDbSessionHandler.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,6 @@
1212
namespace Symfony\Component\HttpFoundation\Session\Storage\Handler;
1313

1414
/**
15-
* MongoDB session handler.
16-
*
1715
* @author Markus Bachmann <[email protected]>
1816
*/
1917
class MongoDbSessionHandler implements \SessionHandlerInterface

src/Symfony/Component/HttpFoundation/Session/Storage/Handler/NativeFileSessionHandler.php

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,24 +12,21 @@
1212
namespace Symfony\Component\HttpFoundation\Session\Storage\Handler;
1313

1414
/**
15-
* NativeFileSessionHandler.
16-
*
1715
* Native session handler using PHP's built in file storage.
1816
*
1917
* @author Drak <[email protected]>
2018
*/
2119
class NativeFileSessionHandler extends NativeSessionHandler
2220
{
2321
/**
24-
* Constructor.
25-
*
2622
* @param string $savePath Path of directory to save session files
2723
* Default null will leave setting as defined by PHP.
2824
* '/path', 'N;/path', or 'N;octal-mode;/path
2925
*
3026
* @see http://php.net/session.configuration.php#ini.session.save-path for further details.
3127
*
3228
* @throws \InvalidArgumentException On invalid $savePath
29+
* @throws \RuntimeException When failing to create the save directory
3330
*/
3431
public function __construct($savePath = null)
3532
{

src/Symfony/Component/HttpFoundation/Session/Storage/Handler/NativeSessionHandler.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,10 @@
1111

1212
namespace Symfony\Component\HttpFoundation\Session\Storage\Handler;
1313

14+
@trigger_error('The '.__NAMESPACE__.'\NativeSessionHandler class is deprecated since version 3.4 and will be removed in 4.0. Use the \SessionHandler class instead.', E_USER_DEPRECATED);
15+
1416
/**
15-
* Adds SessionHandler functionality if available.
16-
*
17+
* @deprecated since version 3.4, to be removed in 4.0. Use \SessionHandler instead.
1718
* @see http://php.net/sessionhandler
1819
*/
1920
class NativeSessionHandler extends \SessionHandler

0 commit comments

Comments
 (0)