Skip to content

[Config] Using PHP to configure "framework.session.handler_id: ~" does not work (falls back to native_file's handler) #42320

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
gnutix opened this issue Jul 29, 2021 · 3 comments

Comments

@gnutix
Copy link
Contributor

gnutix commented Jul 29, 2021

Symfony version(s) affected: 5.3.6

Description
When using PHP files to configure the Framework Bundle, the configuration "framework.session.handler_id" cannot be set to null to use the system's session handler, because the auto-generated class var/cache/{env}/Symfony/Framework/Session/SessionConfig.php class has a check :

if (null !== $this->handlerId) {
    $output['handler_id'] = $this->handlerId;
}

in the method toArray that prevents this valid value from being applied in FrameworkExtension.php (which then falls back to the native file handler). Using the following YAML file next to the PHP one fixes the issue :

framework:
    session:
        handler_id: ~

How to reproduce
Have a PHP file :

<?php # config/packages/framework.php

declare(strict_types=1);

namespace Symfony\Component\DependencyInjection\Loader\Configurator;

use Symfony\Config\FrameworkConfig;

return static function (FrameworkConfig $config): void {
    $config->session()
        ->handlerId(null);
};

Check the session's handler : it's native_file.

Possible Solution
No idea how to resolve this as I can't even find where the auto-generated classes are created, and my guess would be it's quite generic.

Additional context
None.

@gnutix
Copy link
Contributor Author

gnutix commented Aug 4, 2021

An error also occurs when trying to configure this in PHP too : https://symfony.com/doc/current/cache.html#custom-provider-options

Pool cannot have a "provider" while "adapter" is set to a map

In YAML, it just works. I guess it's the same kind of problem.

@gnutix
Copy link
Contributor Author

gnutix commented Jan 26, 2022

I'm quite surprised this issue does not trigger any reaction... 😶

@gnutix
Copy link
Contributor Author

gnutix commented Apr 2, 2022

Confirmed, it's fixed !

$config->session()->handlerId(null);
$ bin/console debug:config framework | grep handler_id
        handler_id: null

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants