Permalink
Browse files

bug #24448 [Session] fix MongoDb session handler to gc all expired se…

…ssions (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
-------

e6895bf [Session] fix MongoDb session handler to gc all expired sessions
  • Loading branch information...
fabpot committed Oct 5, 2017
2 parents cb14798 + e6895bf commit f961aa024fd60c1866296a2cf93086ee317d7fee
@@ -118,7 +118,7 @@ public function destroy($sessionId)
*/
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->options['expiry_field'] => array('$lt' => $this->createDateTime()),
@@ -291,7 +291,7 @@ public function testGc()
$that = $this;
$methodName = phpversion('mongodb') ? 'deleteOne' : 'remove';
$methodName = phpversion('mongodb') ? 'deleteMany' : 'remove';
$collection->expects($this->once())
->method($methodName)

0 comments on commit f961aa0

Please sign in to comment.