Skip to content

Commit 7db556d

Browse files
feature #60876 [HttpFoundation] Deprecate using Request::sendHeaders() after headers have already been sent (nicolas-grekas)
This PR was merged into the 7.4 branch. Discussion ---------- [HttpFoundation] Deprecate using `Request::sendHeaders()` after headers have already been sent | Q | A | ------------- | --- | Branch? | 7.4 | Bug fix? | no | New feature? | no | Deprecations? | no | Issues | - | License | MIT Sibling to #60875 to account for #60603 Commits ------- 6f6fdf0 [HttpFoundation] Deprecate using `Request::sendHeaders()` after headers have already been sent
2 parents 138109a + 6f6fdf0 commit 7db556d

File tree

3 files changed

+12
-1
lines changed

3 files changed

+12
-1
lines changed

UPGRADE-7.4.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,3 +22,8 @@ HttpClient
2222
----------
2323

2424
* Deprecate using amphp/http-client < 5
25+
26+
HttpFoundation
27+
--------------
28+
29+
* Deprecate using `Request::sendHeaders()` after headers have already been sent; use a `StreamedResponse` instead

src/Symfony/Component/HttpFoundation/CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
CHANGELOG
22
=========
33

4+
7.4
5+
---
6+
7+
* Deprecate using `Request::sendHeaders()` after headers have already been sent; use a `StreamedResponse` instead
8+
49
7.3
510
---
611

src/Symfony/Component/HttpFoundation/Response.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -319,7 +319,8 @@ public function sendHeaders(?int $statusCode = null): static
319319
if (headers_sent()) {
320320
if (!\in_array(\PHP_SAPI, ['cli', 'phpdbg', 'embed'], true)) {
321321
$statusCode ??= $this->statusCode;
322-
header(\sprintf('HTTP/%s %s %s', $this->version, $statusCode, $this->statusText), true, $statusCode);
322+
trigger_deprecation('symfony/http-foundation', '7.4', 'Trying to use "%s::sendHeaders()" after headers have already been sent is deprecated will throw a PHP warning in 8.0. Use a "StreamedResponse" instead.', static::class);
323+
//header(\sprintf('HTTP/%s %s %s', $this->version, $statusCode, $this->statusText), true, $statusCode);
323324
}
324325

325326
return $this;

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy