bug #24448 [Session] fix MongoDb session handler to gc all expired sessions (Tobion)
This PR was merged into the 2.7 branch.
Discussion
----------
[Session] fix MongoDb session handler to gc all expired sessions
| Q | A
| ------------- | ---
| Branch? | 2.7
| Bug fix? | yes
| New feature? | no <!-- don't forget to update src/**/CHANGELOG.md files -->
| BC breaks? | no
| Deprecations? | no <!-- don't forget to update UPGRADE-*.md files -->
| Tests pass? | yes
| Fixed tickets |
| License | MIT
| Doc PR |
MongoDB session handler `gc` wrongly only deleted one random expired session instead of all of them.
Care when merging to master as this will conflict with #24447
Commits
-------
e6895bfac5
[Session] fix MongoDb session handler to gc all expired sessions
This commit is contained in:
commit
f961aa024f
|
@ -118,7 +118,7 @@ class MongoDbSessionHandler implements \SessionHandlerInterface
|
||||||
*/
|
*/
|
||||||
public function gc($maxlifetime)
|
public function gc($maxlifetime)
|
||||||
{
|
{
|
||||||
$methodName = $this->mongo instanceof \MongoDB\Client ? 'deleteOne' : 'remove';
|
$methodName = $this->mongo instanceof \MongoDB\Client ? 'deleteMany' : 'remove';
|
||||||
|
|
||||||
$this->getCollection()->$methodName(array(
|
$this->getCollection()->$methodName(array(
|
||||||
$this->options['expiry_field'] => array('$lt' => $this->createDateTime()),
|
$this->options['expiry_field'] => array('$lt' => $this->createDateTime()),
|
||||||
|
|
|
@ -291,7 +291,7 @@ class MongoDbSessionHandlerTest extends TestCase
|
||||||
|
|
||||||
$that = $this;
|
$that = $this;
|
||||||
|
|
||||||
$methodName = phpversion('mongodb') ? 'deleteOne' : 'remove';
|
$methodName = phpversion('mongodb') ? 'deleteMany' : 'remove';
|
||||||
|
|
||||||
$collection->expects($this->once())
|
$collection->expects($this->once())
|
||||||
->method($methodName)
|
->method($methodName)
|
||||||
|
|
Reference in New Issue