8000 [HttpFoundation] Fix Cookie::isCleared by ro0NL · Pull Request #28045 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content

[HttpFoundation] Fix Cookie::isCleared #28045

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 29, 2018
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
[HttpFoundation] Fix Cookie::isCleared
  • Loading branch information
ro0NL committed Jul 23, 2018
commit d3d7766874309f60249f3b0f72518d3149431cd0
2 changes: 1 addition & 1 deletion src/Symfony/Component/HttpFoundation/Cookie.php
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,6 @@ public function isHttpOnly()
*/
public function isCleared()
{
return $this->expire < time();
return 0 !== $this->expire && $this->expire < time();
}
}
12 changes: 12 additions & 0 deletions src/Symfony/Component/HttpFoundation/Tests/CookieTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,18 @@ public function testCookieIsCleared()
$cookie = new Cookie('foo', 'bar', time() - 20);

$this->assertTrue($cookie->isCleared(), '->isCleared() returns true if the cookie has expired');

$cookie = new Cookie('foo', 'bar');

$this->assertFalse($cookie->isCleared());

$cookie = new Cookie('foo', 'bar', 0);

$this->assertFalse($cookie->isCleared());

$cookie = new Cookie('foo', 'bar', -1);

$this->assertFalse($cookie->isCleared());
}

public function testToString()
Expand Down
0