[BrowserKit] Fix cookie expiration on 32 bit systems
On 32-bit systems the cookie expiration value was not being calculated correctly as it was being fetched as an integer. When the timestamp exceeded the PHP_INT_MAX size it would return an invalid value, breaking the cookie construction. The BrowserKit cookie has now been updated to get the timestamp as a string which works around this platform limitation.
This commit is contained in:
parent
2511f2a191
commit
68698f2bd4
@ -76,7 +76,7 @@ class Cookie
|
|||||||
throw new \UnexpectedValueException(sprintf('The cookie expiration time "%s" is not valid.', $expires));
|
throw new \UnexpectedValueException(sprintf('The cookie expiration time "%s" is not valid.', $expires));
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->expires = $timestampAsDateTime->getTimestamp();
|
$this->expires = $timestampAsDateTime->format('U');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -205,13 +205,13 @@ class Cookie
|
|||||||
|
|
||||||
foreach (self::$dateFormats as $dateFormat) {
|
foreach (self::$dateFormats as $dateFormat) {
|
||||||
if (false !== $date = \DateTime::createFromFormat($dateFormat, $dateValue, new \DateTimeZone('GMT'))) {
|
if (false !== $date = \DateTime::createFromFormat($dateFormat, $dateValue, new \DateTimeZone('GMT'))) {
|
||||||
return $date->getTimestamp();
|
return $date->format('U');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// attempt a fallback for unusual formatting
|
// attempt a fallback for unusual formatting
|
||||||
if (false !== $date = date_create($dateValue, new \DateTimeZone('GMT'))) {
|
if (false !== $date = date_create($dateValue, new \DateTimeZone('GMT'))) {
|
||||||
return $date->getTimestamp();
|
return $date->format('U');
|
||||||
}
|
}
|
||||||
|
|
||||||
throw new \InvalidArgumentException(sprintf('Could not parse date "%s".', $dateValue));
|
throw new \InvalidArgumentException(sprintf('Could not parse date "%s".', $dateValue));
|
||||||
@ -304,6 +304,6 @@ class Cookie
|
|||||||
*/
|
*/
|
||||||
public function isExpired()
|
public function isExpired()
|
||||||
{
|
{
|
||||||
return null !== $this->expires && 0 !== $this->expires && $this->expires < time();
|
return null !== $this->expires && 0 != $this->expires && $this->expires < time();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user