Skip to content

Commit 053d67b

Browse files
committed
bug symfony#19827 [BrowserKit] Fix cookie expiration on 32 bit systems (jameshalsall)
This PR was submitted for the master branch but it was merged into the 2.7 branch instead (closes symfony#19827). Discussion ---------- [BrowserKit] Fix cookie expiration on 32 bit systems | Q | A | ------------- | --- | Branch? | 2.7 | Bug fix? | yes | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | symfony#15739 | License | MIT 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 (similar to how it works in the Cookie from HttpFoundation). Commits ------- 68698f2 [BrowserKit] Fix cookie expiration on 32 bit systems
2 parents 2511f2a + 68698f2 commit 053d67b

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

src/Symfony/Component/BrowserKit/Cookie.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ public function __construct($name, $value, $expires = null, $path = null, $domai
7676
throw new \UnexpectedValueException(sprintf('The cookie expiration time "%s" is not valid.', $expires));
7777
}
7878

79-
$this->expires = $timestampAsDateTime->getTimestamp();
79+
$this->expires = $timestampAsDateTime->format('U');
8080
}
8181
}
8282

@@ -205,13 +205,13 @@ private static function parseDate($dateValue)
205205

206206
foreach (self::$dateFormats as $dateFormat) {
207207
if (false !== $date = \DateTime::createFromFormat($dateFormat, $dateValue, new \DateTimeZone('GMT'))) {
208-
return $date->getTimestamp();
208+
return $date->format('U');
209209
}
210210
}
211211

212212
// attempt a fallback for unusual formatting
213213
if (false !== $date = date_create($dateValue, new \DateTimeZone('GMT'))) {
214-
return $date->getTimestamp();
214+
return $date->format('U');
215215
}
216216

217217
throw new \InvalidArgumentException(sprintf('Could not parse date "%s".', $dateValue));
@@ -304,6 +304,6 @@ public function isHttpOnly()
304304
*/
305305
public function isExpired()
306306
{
307-
return null !== $this->expires && 0 !== $this->expires && $this->expires < time();
307+
return null !== $this->expires && 0 != $this->expires && $this->expires < time();
308308
}
309309
}

0 commit comments

Comments
 (0)