Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

[HttpFoundation] Fix return types of SessionHandler::gc() #42114

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 15, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -99,12 +99,13 @@ protected function doDestroy($sessionId)
}

/**
* @return bool
* @return int|false
*/
#[\ReturnTypeWillChange]
public function gc($maxlifetime)
{
// not required here because memcached will auto expire the records anyhow.
return true;
return 0;
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ public function destroy($sessionId)
}

/**
* @return bool
* @return int|false
*/
#[\ReturnTypeWillChange]
public function gc($maxlifetime)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,15 +100,14 @@ protected function doDestroy($sessionId)
}

/**
* @return bool
* @return int|false
*/
#[\ReturnTypeWillChange]
public function gc($maxlifetime)
{
$this->getCollection()->deleteMany([
return $this->getCollection()->deleteMany([
$this->options['expiry_field'] => ['$lt' => new \MongoDB\BSON\UTCDateTime()],
]);

return true;
])->getDeletedCount();
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,11 +70,11 @@ protected function doDestroy($sessionId)
}

/**
* @return bool
* @return int|false
*/
#[\ReturnTypeWillChange]
public function gc($maxlifetime)
{
return true;
return 0;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,7 @@ public function read($sessionId)
}

/**
* @return bool
* @return int|false
*/
#[\ReturnTypeWillChange]
public function gc($maxlifetime)
Expand All @@ -299,7 +299,7 @@ public function gc($maxlifetime)
// This way, pruning expired sessions does not block them from being started while the current session is used.
$this->gcCalled = true;

return true;
return 0;
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,10 +104,13 @@ public function close(): bool

/**
* {@inheritdoc}
*
* @return int|false
*/
public function gc($maxlifetime): bool
#[\ReturnTypeWillChange]
public function gc($maxlifetime)
{
return true;
return 0;
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ public function testDestroySession()

public function testGcSession()
{
$this->assertTrue($this->storage->gc(123));
$this->assertIsInt($this->storage->gc(123));
}

public function testUpdateTimestamp()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,11 +121,12 @@ class TestSessionHandler extends AbstractSessionHandler
return true;
}

public function gc($maxLifetime): bool
#[\ReturnTypeWillChange]
public function gc($maxLifetime)
{
echo __FUNCTION__, "\n";

return true;
return 1;
}

protected function doRead($sessionId): string
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ public function testDestroySession()

public function testGcSession()
{
$this->assertTrue($this->storage->gc(123));
$this->assertIsInt($this->storage->gc(123));
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -184,9 +184,14 @@ public function testGc()
->willReturnCallback(function ($criteria) {
$this->assertInstanceOf(\MongoDB\BSON\UTCDateTime::class, $criteria[$this->options['expiry_field']]['$lt']);
$this->assertGreaterThanOrEqual(time() - 1, round((string) $criteria[$this->options['expiry_field']]['$lt'] / 1000));

$result = $this->createMock(\MongoDB\DeleteResult::class);
$result->method('getDeletedCount')->willReturn(42);

return $result;
});

$this->assertTrue($this->storage->gc(1));
$this->assertSame(42, $this->storage->gc(1));
}

public function testGetConnection()
Expand Down
Morty Proxy This is a proxified and sanitized view of the page, visit original site.