Description
Q | A |
---|---|
Bug report? | yes |
Feature request? | no |
BC Break report? | no |
RFC? | no |
Symfony version | 3.2.4 |
I am trying to implement sessions on the database using https://github.com/shapecode/doctrine-session-handler-bundle. One of the things I need to test is that sessions are being cleaned up using the gc method. So I changed session.gc_probability in php.ini from the red hat default of 1 (out of 1000, most are out of 100) to 1000, to make it try and clear every time. When it wasn't I started echoing the variable in app_dev.php to see what was going on, and found it was being reset somewhere in
$response = $kernel->handle($request);
In order to test this, you can just change the lines (in a new install of Symfony) from:
$request = Request::createFromGlobals();
$response = $kernel->handle($request);
$response->send();
to:
$request = Request::createFromGlobals();
echo ini_get('session.gc_probability');
$response = $kernel->handle($request);
echo ini_get('session.gc_probability');
$response->send();
and look at the results. You should end up with 10001, the 1000 being the first time it is echoed (or whatever value you set this to in php.ini) and then the second time it has been changed to 1.
According to the Symfony documentation at http://symfony.com/doc/current/components/http_foundation/session_configuration.html#configuring-garbage-collection, it uses the values in php.ini to set the chances of gc happening.
This would be ok if it worked properly, as in dev we could set it to 100% of the time to test expiry of sessions (for example from the database). As far as I am aware, it should never change this variable from the value it is set to in php.ini.