Description
Symfony version(s) affected: >=4.4
Description
By introducing the great Symfony\Component\HttpFoundation\Session\Storage\Handler\SessionHandlerFactory it is possible to configure session handler via DSN. But if I want to use the NativeFileSessionHandler to use configured session.save_path of php.ini, it doesn't work as expected because the $savePath constructor param is an empty string (and not NULL) by using "file://" as DSN.
How to reproduce
SessionHandlerFactory::createHandler('file://');
$savePath will be an empty string
https://github.com/symfony/symfony/blob/4.4/src/Symfony/Component/HttpFoundation/Session/Storage/Handler/NativeFileSessionHandler.php#L33
Possible Solution
- check if substr($connection, 7) is an empty string
- if yes use null instead
https://github.com/symfony/symfony/blob/4.4/src/Symfony/Component/HttpFoundation/Session/Storage/Handler/SessionHandlerFactory.php#L51
something like
$savePath = substr('file://', 7);
return new StrictSessionHandler(new NativeFileSessionHandler($savePath === '' ? null: $savePath));
instead of
return new StrictSessionHandler(new NativeFileSessionHandler(substr($connection, 7)));
Additional context