Skip to content

[FrameworkBundle] set default session.handler alias if handler_id is not provided #37572

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

Merged
merged 1 commit into from
Jul 23, 2020

Conversation

ybenhssaien
Copy link
Contributor

Q A
Branch? 3.4
Bug fix? yes
New feature? no
Deprecations? no
Tickets Fix #37245
License MIT
Doc PR

Without a configured handler_id, the session.handler alias is not created, and somes services depend on this alias specialy.

Related to the reported issue above (affected version 4.4.9), the ServiceHandlerInterface is an alias of session.handler, when execute :

  • bin/console debug:container session.handler : The alias is not defined, so the ContainerDebugCommand look for a service containing the session.handler as part of his name (ContainerDebugCommand::findServiceIdsContaining() is called and returns by default session.handler.native_file)
  • bin/console debug:container SessionHandlerInterface : The service is defined as an alias of session.handler, when calling ContainerBuilder::getDefinition('session.handler') the exception occured as the alias is not defined.

Implemented solution

Create a default session.handler when the param handler_id is not provided (I choosed session.handler.native_file rather than NullSessionHandler).

Affected versions

From 3.4 to 5.1

@ybenhssaien ybenhssaien changed the title #37245 set default alias to session.handler #37245 set default session.handler alias if handler_id is not provided Jul 14, 2020
@nicolas-grekas nicolas-grekas added this to the 3.4 milestone Jul 22, 2020
@nicolas-grekas nicolas-grekas changed the title #37245 set default session.handler alias if handler_id is not provided [FrameworkBundle] set default session.handler alias if handler_id is not provided Jul 22, 2020
@@ -463,6 +463,7 @@ public function testNullSessionHandler()
$this->assertTrue($container->hasDefinition('session'), '->registerSessionConfiguration() loads session.xml');
$this->assertNull($container->getDefinition('session.storage.native')->getArgument(1));
$this->assertNull($container->getDefinition('session.storage.php_bridge')->getArgument(0));
$this->assertEquals('session.handler.native_file', (string) $container->getAlias('session.handler'));
Copy link
Member

Choose a reason for hiding this comment

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

please use assertSame()

@fabpot fabpot force-pushed the session_handler_default branch from abc9ea0 to 46c8c37 Compare July 23, 2020 06:40
@fabpot
Copy link
Member

fabpot commented Jul 23, 2020

Thank you @ybenhssaien.

@fabpot fabpot merged commit 09c97bd into symfony:3.4 Jul 23, 2020
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.

4 participants