Skip to content

Commit 265d4b2

Browse files
feature #61180 [HttpFoundation] Trigger PHP warning when using Request::sendHeaders() after headers have already been sent (nicolas-grekas)
This PR was merged into the 8.0 branch. Discussion ---------- [HttpFoundation] Trigger PHP warning when using `Request::sendHeaders()` after headers have already been sent | Q | A | ------------- | --- | Branch? | 8.0 | Bug fix? | no | New feature? | yes | Deprecations? | no | Issues | - | License | MIT Commits ------- 1c64caa [HttpFoundation] Trigger PHP warning when using `Request::sendHeaders()` after headers have already been sent
2 parents eaecccb + 1c64caa commit 265d4b2

File tree

4 files changed

+3
-3
lines changed

4 files changed

+3
-3
lines changed

UPGRADE-8.0.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -219,6 +219,7 @@ HttpFoundation
219219
--------------
220220

221221
* Remove the following deprecated session options from `NativeSessionStorage`: `referer_check`, `use_only_cookies`, `use_trans_sid`, `sid_length`, `sid_bits_per_character`, `trans_sid_hosts`, `trans_sid_tags`
222+
* Trigger PHP warning when using `Request::sendHeaders()` after headers have already been sent; use a `StreamedResponse` instead
222223

223224
HttpClient
224225
----------

src/Symfony/Component/HttpFoundation/CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ CHANGELOG
55
---
66

77
* Remove the following deprecated session options from `NativeSessionStorage`: `referer_check`, `use_only_cookies`, `use_trans_sid`, `sid_length`, `sid_bits_per_character`, `trans_sid_hosts`, `trans_sid_tags`
8+
* Trigger PHP warning when using `Request::sendHeaders()` after headers have already been sent; use a `StreamedResponse` instead
89

910
7.4
1011
---

src/Symfony/Component/HttpFoundation/Response.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -319,8 +319,7 @@ 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-
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);
322+
header(\sprintf('HTTP/%s %s %s', $this->version, $statusCode, $this->statusText), true, $statusCode);
324323
}
325324

326325
return $this;

src/Symfony/Component/HttpFoundation/composer.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
],
1818
"require": {
1919
"php": ">=8.4",
20-
"symfony/deprecation-contracts": "^2.5|^3.0",
2120
"symfony/polyfill-mbstring": "^1.1"
2221
},
2322
"require-dev": {

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