8000 Merge branch '3.2' · symfony/symfony@69264ff · GitHub
[go: up one dir, main page]

Skip to content

Commit 69264ff

Browse files
committed
Merge branch '3.2'
* 3.2: [HttpKernel] Continuation of #20599 for 3.1 Add missing upgrade path for Request::isMethodSafe() deprecation
2 parents d29fc2c + 072393d commit 69264ff

File tree

3 files changed

+9
-42
lines changed

3 files changed

+9
-42
lines changed

UPGRADE-3.2.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,11 @@ HttpFoundation
9494
- `isInvalid`/`isSuccessful`/`isRedirection`/`isClientError`/`isServerError`
9595
- `isOk`/`isForbidden`/`isNotFound`/`isRedirect`/`isEmpty`
9696

97+
* Checking only for cacheable HTTP methods with `Request::isMethodSafe()` is deprecated
98+
since version 3.2 and will throw an exception in 4.0. Disable checking only for
99+
cacheable methods by calling the method with `false` as first argument or use
100+
`Request::isMethodCacheable()` instead.
101+
97102
HttpKernel
98103
----------
99104

UPGRADE-4.0.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,9 @@ HttpFoundation
173173
- `isInvalid`/`isSuccessful`/`isRedirection`/`isClientError`/`isServerError`
174174
- `isOk`/`isForbidden`/`isNotFound`/`isRedirect`/`isEmpty`
175175

176+
* The ability to check only for cacheable HTTP methods using `Request::isMethodSafe()` is
177+
not supported anymore, use `Request::isMethodCacheable()` instead.
178+
176179
HttpKernel
177180
----------
178181

src/Symfony/Component/HttpKernel/DataCollector/RequestDataCollector.php

Lines changed: 1 addition & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -40,12 +40,8 @@ public function __construct()
4040
public function collect(Request $request, Response $response, \Exception $exception = null)
4141
{
4242
$responseHeaders = $response->headers->all();
43-
$cookies = array();
4443
foreach ($response->headers->getCookies() as $cookie) {
45-
$cookies[] = $this->getCookieHeader($cookie->getName(), $cookie->getValue(), $cookie->getExpiresTime(), $cookie->getPath(), $cookie->getDomain(), $cookie->isSecure(), $cookie->isHttpOnly());
46-
}
47-
if (count($cookies) > 0) {
48-
$responseHeaders['Set-Cookie'] = $cookies;
44+
$responseHeaders['set-cookie'][] = (string) $cookie;
4945
}
5046

5147
// attributes are serialized and as they can be anything, they need to be converted to strings.
@@ -403,41 +399,4 @@ protected function parseController($controller)
403399

404400
return is_string($controller) ? $controller : 'n/a';
405401
}
406-
407-
private function getCookieHeader($name, $value, $expires, $path, $domain, $secure, $httponly)
408-
{
409-
$cookie = sprintf('%s=%s', $name, urlencode($value));
410-
411-
if (0 !== $expires) {
412-
if (is_numeric($expires)) {
413-
$expires = (int) $expires;
414-
} elseif ($expires instanceof \DateTime) {
415-
$expires = $expires->getTimestamp();
416-
} else {
417-
$tmp = strtotime($expires);
418-
if (false === $tmp || -1 == $tmp) {
419-
throw new \InvalidArgumentException(sprintf('The "expires" cookie parameter is not valid (%s).', $expires));
420-
}
421-
$expires = $tmp;
422-
}
423-
424-
$cookie .= '; expires='.str_replace('+0000', '', \DateTime::createFromFormat('U', $expires, new \DateTimeZone('GMT'))->format('D, d-M-Y H:i:s T'));
425-
}
426-
427-
if ($domain) {
428-
$cookie .= '; domain='.$domain;
429-
}
430-
431-
$cookie .= '; path='.$path;
432-
433-
if ($secure) {
434-
$cookie .= '; secure';
435-
}
436-
437-
if ($httponly) {
438-
$cookie .= '; httponly';
439-
}
440-
441-
return $cookie;
442-
}
443402
}

0 commit comments

Comments
 (0)
0