-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[HttpFoundation][Cookie] Cookie DateTimeInterface fix #17370
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
Conversation
@@ -51,7 +51,7 @@ public function __construct($name, $value = null, $expire = 0, $path = '/', $dom | |||
} | |||
|
|||
// convert expiration time to a Unix timestamp | |||
if ($expire instanceof \DateTime) { | |||
if ($expire instanceof \DateTimeInterface) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this does not work on PHP 5.3
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
instanceof \DateTime || instanceof \DateTimeInterface
Closed in favor of #17371 |
Well, we could still additionally check for |
@@ -85,6 +85,14 @@ public function testConstructorWithDateTime() | |||
$this->assertEquals($expire->format('U'), $cookie->getExpiresTime(), '->getExpiresTime() returns the expire date'); | |||
} | |||
|
|||
public function testConstructorWithDateTimeImmutable() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@requires PHP 5.5
annotation
👍 Status: Reviewed |
Thank you @wildewouter. |
…dewouter) This PR was squashed before being merged into the 2.3 branch (closes #17370). Discussion ---------- [HttpFoundation][Cookie] Cookie DateTimeInterface fix | Q | A | ------------- | --- | Bug fix? | yes | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | - | License | MIT | Doc PR | - I came across an issue with expiration times on cookies. They were not working with DateTimeImmutable but only the DateTime implementation itself. I refactored this to work with the DateTimeInterface. Commits ------- f1f9754 [HttpFoundation][Cookie] Cookie DateTimeInterface fix
I came across an issue with expiration times on cookies. They were not working with DateTimeImmutable but only the DateTime implementation itself. I refactored this to work with the DateTimeInterface.