Skip to content

Commit

Permalink
bug #24448 [Session] fix MongoDb session handler to gc all expired se…
Browse files Browse the repository at this point in the history
…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 f961aa0
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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()),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit f961aa0

Please sign in to comment.