Skip to content

[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

Closed
wants to merge 3 commits into from

Conversation

afurculita
Copy link
Contributor

@afurculita afurculita commented Sep 17, 2017

Q A
Branch? 3.4
Bug fix? no
New feature? no
BC breaks? no
Deprecations? yes
Tests pass? yes
Fixed tickets -
License MIT
Doc PR -

This PR removes functionality added in Symfony 2.1 as a compatibility layer with sessions from PHP <5.4.

  • Fix tests

*
* @throws \InvalidArgumentException
*/
public function setSaveHandler($saveHandler = null)
{
if (!$saveHandler instanceof AbstractProxy &&
!$saveHandler instanceof NativeSessionHandler &&
Copy link
Member

@nicolas-grekas nicolas-grekas Sep 17, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should be reverted as that's a BC break, isn't it?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nope, since Symfony 3.0, NativeSessionHandler always extends \SessionHandler. Thus now the rule !$saveHandler instanceof NativeSessionHandler is covered by !$saveHandler instanceof \SessionHandlerInterface

@afurculita afurculita force-pushed the 3.4 branch 2 times, most recently from 640661c to 71a92a2 Compare September 17, 2017 15:24
@@ -12,7 +12,7 @@
namespace Symfony\Component\HttpFoundation\Session\Storage\Proxy;

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

shouldn't you add a deprecated notice here ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I had one, but removed it because AbstractProxy is extended by SessionHandlerProxy and this will make the tests that use SessionHandlerProxy to not pass. I can't mark these tests as legacy. What's a good solution to have a deprecation notice here and tests pass?

@@ -12,8 +12,6 @@
namespace Symfony\Component\HttpFoundation\Session\Storage\Proxy;

/**
* SessionHandler proxy.
*
* @author Drak <drak@zikula.org>
*/
class SessionHandlerProxy extends AbstractProxy implements \SessionHandlerInterface
Copy link
Contributor Author

@afurculita afurculita Sep 17, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would also move this class from the Proxy folder to Handler. What do you think, @nicolas-grekas ?

Copy link
Member

Choose a reason for hiding this comment

The 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.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the SessionHandlerProxy can be deprecated as well. When we only support \SessionHandlerInterface anyway, the proxy does not provide any value anymore AFAIK. I was meant as a way to make \SessionHandlerInterface and others behave the same.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was thinking the same. The extra methods that SessionHandlerProxy is having can easily be moved to NativeSessionStorage as they are relevant only for a native session storage.

Copy link
Contributor

@sstok sstok left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some minor comments on the changelog, but it seems the HttpFoundation also has this rather strange commentary usage.

UPGRADE-3.4.md Outdated
@@ -205,6 +205,25 @@ FrameworkBundle
HttpKernel
----------

* the `Symfony\Component\HttpFoundation\Session\Storage\Handler\NativeSessionHandler`
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing capital in the sentence (see other lines in this file).

And each line is separated by a single white line.

UPGRADE-3.4.md Outdated
* `NativeSessionStorage::setSaveHandler()` now takes an instance of `\SessionHandlerInterface` as argument.
Not passing it is deprecated and will throw a `TypeError` in 4.0.

HttpKernel
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Duplicate header (wrong rebase?)

@@ -205,6 +205,25 @@ FrameworkBundle
HttpKernel
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This header should be HttpFoundation

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed

@afurculita afurculita force-pushed the 3.4 branch 2 times, most recently from 845d5a6 to f275707 Compare September 18, 2017 10:31
@afurculita
Copy link
Contributor Author

Comments addressed :)

UPGRADE-3.4.md Outdated
@@ -202,6 +202,30 @@ FrameworkBundle
`TranslationDebugCommand`, `TranslationUpdateCommand`, `XliffLintCommand`
and `YamlLintCommand` classes have been marked as final

HttpFoundation
----------
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

wrong number of dashes :)

@xabbuh
Copy link
Member

xabbuh commented Sep 20, 2017

Please also update the UPGRADE-4.0.md file.

@afurculita afurculita force-pushed the 3.4 branch 2 times, most recently from 415ddf0 to 46c0740 Compare September 24, 2017 19:33
@afurculita
Copy link
Contributor Author

Ready for review. I've also deprecated SessionHandlerProxy

Alexandru Furculita and others added 2 commits September 24, 2017 22:38
Signed-off-by: Alexandru Furculita <alex@furculita.net>
Signed-off-by: Alexandru Furculita <alex@furculita.net>
@@ -198,17 +198,17 @@ public function testSetSaveHandler()
$this->iniSet('session.save_handler', 'files');
$storage = $this->getStorage();
$storage->setSaveHandler();
$this->assertInstanceOf('Symfony\Component\HttpFoundation\Session\Storage\Proxy\SessionHandlerProxy', $storage->getSaveHandler());
$this->assertInstanceOf(SessionHandlerProxy::class, $storage->getSaveHandler());
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we don't change that to avoid conflicts unless the line needs to be touched anyway. so this should be reverted.

*
* @param AbstractProxy|NativeSessionHandler|\SessionHandlerInterface|null $handler
* @param MetadataBag $metaBag MetadataBag
* @param AbstractProxy|\SessionHandlerInterface|null $handler
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Argument types that are deprecated should be removed from the doc

* @param AbstractProxy|NativeSessionHandler|\SessionHandlerInterface|null $handler
* @param MetadataBag $metaBag MetadataBag
* @param array $options Session configuration options
* @param AbstractProxy|\SessionHandlerInterface|null $handler
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same, AbstractProxy should not be documented anymore

@nicolas-grekas
Copy link
Member

@Tobion OK for you? Can I let you merge if yes?

@Tobion
Copy link
Contributor

Tobion commented Sep 26, 2017

Thank you @afurculita.

Tobion added a commit that referenced this pull request Sep 26, 2017
… sessions (afurculita)

This PR was squashed before being merged into the 3.4 branch (closes #24239).

Discussion
----------

[HttpFoundation] Deprecate compatibility with PHP <5.4 sessions

| Q             | A
| ------------- | ---
| Branch?       | 3.4
| Bug fix?      | no
| New feature?  | no
| BC breaks?    | no
| Deprecations? | yes
| Tests pass?   | yes
| Fixed tickets | -
| License       | MIT
| Doc PR        | -

This PR removes functionality added in Symfony 2.1 as a compatibility layer with sessions from PHP <5.4.

- [x] Fix tests

Commits
-------

3deb394 [HttpFoundation] Deprecate compatibility with PHP <5.4 sessions
@Tobion Tobion closed this Sep 26, 2017
@afurculita afurculita deleted the 3.4 branch September 26, 2017 12:26
@afurculita afurculita restored the 3.4 branch September 26, 2017 12:26
@Tobion
Copy link
Contributor

Tobion commented Sep 26, 2017

@afurculita could you work on a PR against master to remove the deprecated stuff? Would be much appreciated.

@afurculita
Copy link
Contributor Author

@Tobion already started it ;)

fabpot added a commit that referenced this pull request Sep 27, 2017
…5.4 sessions (afurculita)

This PR was merged into the 4.0-dev branch.

Discussion
----------

[HttpFoundation] Removed compatibility layer for PHP <5.4 sessions

| Q             | A
| ------------- | ---
| Branch?       | master
| Bug fix?      | no
| New feature?  | yes
| BC breaks?  | yes
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | -
| License       | MIT
| Doc PR        | -

This is a follow-up of #24239. This PR removes the compatibility layer added for sessions for PHP <5.4.

Commits
-------

37d1a21 Removed compatibility layer for PHP <5.4 sessions
This was referenced Oct 18, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants