Merge conflict Gerrit cannot merge this change. It needs a rebase onto main.
91383[TASK] Followup on output buffering removal
Commit message
Test this change
Run a command in your clone of the TYPO3 Core. Then try what the change does and vote on Verified in Gerrit. How to review a patch
- Check out patch set 5
-
git fetch https://review.typo3.org/Packages/TYPO3.CMS refs/changes/83/91383/5 && git checkout FETCH_HEAD - Cherry-pick onto main
-
git fetch https://review.typo3.org/Packages/TYPO3.CMS refs/changes/83/91383/5 && git cherry-pick FETCH_HEAD
Review
-
Code review CR -1 Needs a vote
- Benjamin Franzke -1
-
Verified V 0 Needs a vote
- core-ci +1 CI
Issues 2
Files 5
- typo3/sysext/core/Classes/Console/CommandApplication.php+0 −7
- typo3/sysext/core/Classes/Core/SystemEnvironmentBuilder.php+6 −0
- typo3/sysext/core/Classes/Http/AbstractApplication.php+0 −3
- typo3/sysext/core/Classes/Utility/DebugUtility.php5+0 −5
- typo3/sysext/frontend/Classes/Middleware/EidHandler.php+0 −3
Review log 1924
-
Benjamin Franzke uploaded patch set 1 10/31/25, 05:40
-
core-ci voted on patch set 1 V -1 10/31/25, 05:55 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/88226
-
Benjamin Franzke uploaded patch set 2
V -110/31/25, 08:59 -
core-ci voted on patch set 2 V -1 10/31/25, 09:13 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/88233
-
Benni Mack commented on patch set 2 10/31/25, 09:24
Hey, while on this topic... this is the last part we should tackle https://github.com/TYPO3/typo3/blob/main/typo3/sysext/extbase/Classes/Core/Bootstrap.php#L175 -
Benjamin Franzke marked it work in progress 10/31/25, 11:02
-
Benni Mack commented on patch set 2 07/29/26, 13:39
see this change, I actually decided to keep the "leftover" https://review.typo3.org/c/Packages/TYPO3.CMS/+/94863 which we could also remvoe -
Benjamin Franzke commented on patch set 2 07/31/26, 07:15
Reply
Why did you decide to keep it? -
Benjamin Franzke uploaded patch set 3
V -107/31/26, 07:32 -
Benjamin Franzke commented on patch set 3 07/31/26, 07:32
Reply
I've rebased this patch to show the difference of this patch to yours, so we can discuss based on code. -
core-ci voted on patch set 3 V -1 07/31/26, 07:50 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/105740
-
Benni Mack commented on patch set 3 07/31/26, 08:29
Reply
see CI -
Benjamin Franzke uploaded patch set 4
V -107/31/26, 08:51 -
Benjamin Franzke commented on patch set 4 07/31/26, 08:56
Reply
I don't understand that, why did that cause to keep the leftovers in AbstractApplication, DebugUtility and EidHandler? CI failed because I always cleared in SystemEnvironmentBuilder, which current main does only do in CommandApplication (which I think is not correct, because if it's required there, then it would be needed in other cases as well, not just in the command application). As mentioned in the commit message: We could try to protect from misbehaving extensions by throwing if there is an open output buffer after localconf loading, but then again it will break because phpunit always opens a output buffer (which is kinda ugly for us, since we can not test in "real" operation mode, but anyway). Anyway: I've pushed another fix to account for phpunit, let's see if this works out and if we can therefore agree on a removal. -
core-ci voted on patch set 4 V +1 07/31/26, 08:58 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/105746
-
Benjamin Franzke updated the commit message in patch set 5
V +107/31/26, 09:19 -
core-ci voted on patch set 5 V +1 07/31/26, 09:27 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/105748
-
Garvin Hicking commented on patch set 5 07/31/26, 11:05
DebugUtility.php:39Isn't this required to be able to capture warnings/notices to reveal them within the debug dump rather than "outside"? -
Garvin Hicking commented on patch set 5 07/31/26, 11:10
DebugUtility.php:39Reply(I mean things done with "echo" in cowboy debugging, which is what this method might be used in ;) -
Benjamin Franzke commented on patch set 5 CR -1 07/31/26, 12:31
DebugUtility.php:39ReplyI don't get how a warning would be captured by calling `ob_start()` in here? This could actually only caused output buffering to be enable when it was disabled. Maybe you mean: Won't an immediate echo cause an "Headers already sent" error later – or "better" cause us to not send headers at all, since we call `headers_sent()` before sending headers. Didn't check that aspect. -1 for now. -
Garvin Hicking commented on patch set 5 07/31/26, 15:55
DebugUtility.php:39Reply UnresolvedOut of time today, I'll try to draft an example what I meant, and see if it actually would do what I'm thinking of. -
Garvin Hicking commented on patch set 5 07/31/26, 17:55
DebugUtility.php:42UnresolvedOk so this is a bit of a rabbit hole. We COULD remove this line here, but then introducing: if (ini_get('output_buffering')) { ob_end_clean(); } make the actual trouble. The reason here is that most often, PHP has a output_buffering=4096 set (as far as I can see in stock installs). So that means, due to that, the ob_get_level() could never have been 0 before. This line here was a no-op and never really triggered in WEB-context. With the current patch set, it COULD trigger in web context, and then would discarad any headers that have been sent after a debug() call was added. You can simulate this via: ``` diff --git a/typo3/sysext/core/Classes/Middleware/NormalizedParamsAttribute.php b/typo3/sysext/core/Classes/Middleware/NormalizedParamsAttribute.php index a10e32d0274..2804e48c3ef 100644 --- a/typo3/sysext/core/Classes/Middleware/NormalizedParamsAttribute.php +++ b/typo3/sysext/core/Classes/Middleware/NormalizedParamsAttribute.php @@ -22,6 +22,7 @@ use Psr\Http\Message\ServerRequestInterface; use Psr\Http\Server\MiddlewareInterface; use Psr\Http\Server\RequestHandlerInterface; use TYPO3\CMS\Core\Http\NormalizedParams; +use TYPO3\CMS\Core\Utility\DebugUtility; /** * Add NormalizedParams as 'normalizedParams' attribute. @@ -41,6 +42,28 @@ readonly class NormalizedParamsAttribute implements MiddlewareInterface if ($normalizedParams === null) { $request = $request->withAttribute('normalizedParams', NormalizedParams::createFromRequest($request)); } - return $handler->handle($request); + + // Call any FE or BE URL with ?headerDebug=true and compare: + // with the ob_start() branch: X-Header-Debug is in the response + // without the ob_start() branch: no X-Header-Debug, Content-Type is PHP's default + $headerDebug = in_array($request->getQueryParams()['headerDebug'] ?? null, ['true', '1'], true); + if ($headerDebug) { + // A stray debug() call + DebugUtility::debug(['answer' => 42], '1stray debug call'); + } + + $response = $handler->handle($request); + + if ($headerDebug) { + $response = $response + ->withHeader('X-Header-Debug', 'response-headers-survived') + ->withHeader('X-Header-Debug-Ob-Level', (string)ob_get_level()) + // The dump is prepended to the body outside of the PSR-7 message, so the + // announced Content-Length would cut the page off. See the class comment + // of ContentLengthResponseHeader. + ->withoutHeader('Content-Length'); + } + + return $response; } } ``` When the line is removed from the debug() method, the extra headers added in the middleware no longer are emitted. Only having that ob_buffering would ensure that custom extra headers would survive possible debug outputs. I think I'm not describing this very well, but do you get my point? I guess we could leave that statement in here (with a comment why) - otherwise we'd have to think about the PHP "output_buffering" gate?! -
Benni Mack commented on patch set 5 08/01/26, 05:47
Reply Unresolved
I feel this is a chicken-egg problem if we add this change in SystemEnvironmentBuilder. If we use a PHP framework and call TYPO3 inside of it (= SystemEnvironmentbUilder) everything would be discarded until then. We should rather just send it to the client. I don't think we should worry about the php.ini flag, but rather consider flushing everything out (we could / should centralize this though). But here we go, finding ways to deal with PHPUnit again. Another option is to actually flushing to a specific baseline (= PHPUnit) at the end, thus we need to keep this code (but again: centralizing the pieces of code). -
Benjamin Franzke marked it work in progress 09/15/26, 13:20