-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[HttpFoundation] Deprecate compatibility with PHP <5.4 sessions #24239
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
Signed-off-by: Alexandru Furculita <alex@furculita.net>
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -205,6 +205,30 @@ FrameworkBundle | |
`TranslationDebugCommand`, `TranslationUpdateCommand`, `XliffLintCommand` | ||
and `YamlLintCommand` classes have been marked as final | ||
|
||
HttpFoundation | ||
-------------- | ||
|
||
* The `Symfony\Component\HttpFoundation\Session\Storage\Handler\NativeSessionHandler` | ||
class has been deprecated and will be removed in 4.0. Use the `\SessionHandler` class instead. | ||
|
||
* The `Symfony\Component\HttpFoundation\Session\Storage\Proxy\AbstractProxy` class has been | ||
deprecated and will be removed in 4.0. Use the `Symfony\Component\HttpFoundation\Session\Storage\Proxy\SessionHandlerProxy` | ||
class instead. | ||
|
||
* The `Symfony\Component\HttpFoundation\Session\Storage\Proxy\NativeProxy` class has been | ||
deprecated and will be removed in 4.0. Use the `Symfony\Component\HttpFoundation\Session\Storage\Proxy\SessionHandlerProxy` | ||
class instead. | ||
|
||
* The `Symfony\Component\HttpFoundation\Session\Storage\Proxy\SessionHandlerProxy::isSessionHandlerInterface()` | ||
method has been deprecated and will be removed in 4.0. | ||
|
||
* The `Symfony\Component\HttpFoundation\Session\Storage\Proxy\SessionHandlerProxy::isWrapper()` | ||
method has been deprecated and will be removed in 4.0. You can check explicitly if the proxy wraps | ||
a `\SessionHandler` instance. | ||
|
||
* `NativeSessionStorage::setSaveHandler()` now takes an instance of `\SessionHandlerInterface` as argument. | ||
Not passing it is deprecated and will throw a `TypeError` in 4.0. | ||
|
||
HttpKernel | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This header should be There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fixed |
||
---------- | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,7 +13,6 @@ | |
|
||
use Symfony\Component\Debug\Exception\ContextErrorException; | ||
use Symfony\Component\HttpFoundation\Session\SessionBagInterface; | ||
use Symfony\Component\HttpFoundation\Session\Storage\Handler\NativeSessionHandler; | ||
use Symfony\Component\HttpFoundation\Session\Storage\Proxy\AbstractProxy; | ||
use Symfony\Component\HttpFoundation\Session\Storage\Proxy\SessionHandlerProxy; | ||
|
||
|
@@ -97,9 +96,9 @@ class NativeSessionStorage implements SessionStorageInterface | |
* trans_sid_hosts, $_SERVER['HTTP_HOST'] | ||
* trans_sid_tags, "a=href,area=href,frame=src,form=" | ||
* | ||
* @param array $options Session configuration options | ||
* @param AbstractProxy|NativeSessionHandler|\SessionHandlerInterface|null $handler | ||
* @param MetadataBag $metaBag MetadataBag | ||
* @param array $options Session configuration options | ||
* @param AbstractProxy|\SessionHandlerInterface|null $handler | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. same, AbstractProxy should not be documented anymore |
||
* @param MetadataBag $metaBag MetadataBag | ||
*/ | ||
public function __construct(array $options = array(), $handler = null, MetadataBag $metaBag = null) | ||
{ | ||
|
@@ -276,7 +275,7 @@ public function getBag($name) | |
throw new \InvalidArgumentException(sprintf('The SessionBagInterface %s is not registered.', $name)); | ||
} | ||
|
||
if ($this->saveHandler->isActive() && !$this->started) { | ||
if (!$this->started && $this->saveHandler->isActive()) { | ||
$this->loadSession(); | ||
} elseif (!$this->started) { | ||
$this->start(); | ||
|
@@ -358,7 +357,7 @@ public function setOptions(array $options) | |
* ini_set('session.save_handler', 'files'); | ||
* ini_set('session.save_path', '/tmp'); | ||
* | ||
* or pass in a NativeSessionHandler instance which configures session.save_handler in the | ||
* or pass in a \SessionHandler instance which configures session.save_handler in the | ||
* constructor, for a template see NativeFileSessionHandler or use handlers in | ||
* composer package drak/native-session | ||
* | ||
|
@@ -367,17 +366,16 @@ public function setOptions(array $options) | |
* @see http://php.net/sessionhandler | ||
* @see http://github.com/drak/NativeSession | ||
* | ||
* @param AbstractProxy|NativeSessionHandler|\SessionHandlerInterface|null $saveHandler | ||
* @param AbstractProxy|\SessionHandlerInterface|null $saveHandler | ||
* | ||
* @throws \InvalidArgumentException | ||
*/ | ||
public function setSaveHandler($saveHandler = null) | ||
{ | ||
if (!$saveHandler instanceof AbstractProxy && | ||
!$saveHandler instanceof NativeSessionHandler && | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. should be reverted as that's a BC break, isn't it? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nope, since Symfony 3.0, |
||
!$saveHandler instanceof \SessionHandlerInterface && | ||
null !== $saveHandler) { | ||
throw new \InvalidArgumentException('Must be instance of AbstractProxy or NativeSessionHandler; implement \SessionHandlerInterface; or be null.'); | ||
throw new \InvalidArgumentException('Must be instance of AbstractProxy; implement \SessionHandlerInterface; or be null.'); | ||
} | ||
|
||
// Wrap $saveHandler in proxy and prevent double wrapping of proxy | ||
|
@@ -390,6 +388,8 @@ public function setSaveHandler($saveHandler = null) | |
|
||
if ($this->saveHandler instanceof \SessionHandlerInterface) { | ||
session_set_save_handler($this->saveHandler, false); | ||
} else { | ||
@trigger_error('Using session save handlers that do not implement \SessionHandlerInterface is deprecated since version 3.4 and will be removed in 4.0.', E_USER_DEPRECATED); | ||
} | ||
} | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,7 +12,6 @@ | |
namespace Symfony\Component\HttpFoundation\Session\Storage; | ||
|
||
use Symfony\Component\HttpFoundation\Session\Storage\Proxy\AbstractProxy; | ||
use Symfony\Component\HttpFoundation\Session\Storage\Handler\NativeSessionHandler; | ||
|
||
/** | ||
* Allows session to be started by PHP and managed by Symfony. | ||
|
@@ -24,8 +23,8 @@ class PhpBridgeSessionStorage extends NativeSessionStorage | |
/** | ||
* Constructor. | ||
* | ||
* @param AbstractProxy|NativeSessionHandler|\SessionHandlerInterface|null $handler | ||
* @param MetadataBag $metaBag MetadataBag | ||
* @param AbstractProxy|\SessionHandlerInterface|null $handler | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Argument types that are deprecated should be removed from the doc |
||
* @param MetadataBag $metaBag MetadataBag | ||
*/ | ||
public function __construct($handler = null, MetadataBag $metaBag = null) | ||
{ | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,7 +12,7 @@ | |
namespace Symfony\Component\HttpFoundation\Session\Storage\Proxy; | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. shouldn't you add a deprecated notice here ? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I had one, but removed it because |
||
/** | ||
* AbstractProxy. | ||
* @deprecated since version 3.4, to be removed in 4.0. Use SessionHandlerProxy instead. | ||
* | ||
* @author Drak <drak@zikula.org> | ||
*/ | ||
|
@@ -21,6 +21,8 @@ abstract class AbstractProxy | |
/** | ||
* Flag if handler wraps an internal PHP session handler (using \SessionHandler). | ||
* | ||
* @deprecated since version 3.4 and will be removed in 4.0. | ||
* | ||
* @var bool | ||
*/ | ||
protected $wrapper = false; | ||
|
@@ -43,20 +45,28 @@ public function getSaveHandlerName() | |
/** | ||
* Is this proxy handler and instance of \SessionHandlerInterface. | ||
* | ||
* @deprecated since version 3.4 and will be removed in 4.0. | ||
* | ||
* @return bool | ||
*/ | ||
public function isSessionHandlerInterface() | ||
{ | ||
@trigger_error('isSessionHandlerInterface() is deprecated since version 3.4 and will be removed in 4.0. A session handler proxy should always implement \SessionHandlerInterface.', E_USER_DEPRECATED); | ||
|
||
return $this instanceof \SessionHandlerInterface; | ||
} | ||
|
||
/** | ||
* Returns true if this handler wraps an internal PHP session save handler using \SessionHandler. | ||
* | ||
* @deprecated since version 3.4 and will be removed in 4.0. | ||
* | ||
* @return bool | ||
*/ | ||
public function isWrapper() | ||
{ | ||
@trigger_error('isWrapper() is deprecated since version 3.4 and will be removed in 4.0. You should explicitly check if the handler proxy wraps a \SessionHandler instance.', E_USER_DEPRECATED); | ||
|
||
return $this->wrapper; | ||
} | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,8 +12,6 @@ | |
namespace Symfony\Component\HttpFoundation\Session\Storage\Proxy; | ||
|
||
/** | ||
* SessionHandler proxy. | ||
* | ||
* @author Drak <drak@zikula.org> | ||
*/ | ||
class SessionHandlerProxy extends AbstractProxy implements \SessionHandlerInterface | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I would also move this class from the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That would need deprecating this class in favor of the new one, and allow triggering a deprecation in AbstractProxy also. LGTM. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I was thinking the same. The extra methods that |
||
|
@@ -23,11 +21,6 @@ class SessionHandlerProxy extends AbstractProxy implements \SessionHandlerInterf | |
*/ | ||
protected $handler; | ||
|
||
/** | ||
* Constructor. | ||
* | ||
* @param \SessionHandlerInterface $handler | ||
*/ | ||
public function __construct(\SessionHandlerInterface $handler) | ||
{ | ||
$this->handler = $handler; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Duplicate header (wrong rebase?)