Skip to content

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

Closed
@gnutix

Description

@gnutix

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.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions