Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit f961aa0

Browse files
committed
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 ------- e6895bf [Session] fix MongoDb session handler to gc all expired sessions
2 parents cb14798 + e6895bf commit f961aa0

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

src/Symfony/Component/HttpFoundation/Session/Storage/Handler/MongoDbSessionHandler.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ public function destroy($sessionId)
118118
*/
119119
public function gc($maxlifetime)
120120
{
121-
$methodName = $this->mongo instanceof \MongoDB\Client ? 'deleteOne' : 'remove';
121+
$methodName = $this->mongo instanceof \MongoDB\Client ? 'deleteMany' : 'remove';
122122

123123
$this->getCollection()->$methodName(array(
124124
$this->options['expiry_field'] => array('$lt' => $this->createDateTime()),

src/Symfony/Component/HttpFoundation/Tests/Session/Storage/Handler/MongoDbSessionHandlerTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -291,7 +291,7 @@ public function testGc()
291291

292292
$that = $this;
293293

294-
$methodName = phpversion('mongodb') ? 'deleteOne' : 'remove';
294+
$methodName = phpversion('mongodb') ? 'deleteMany' : 'remove';
295295

296296
$collection->expects($this->once())
297297
->method($methodName)

0 commit comments

Comments
 (0)