ob handler should not print the output in case of callback exception
Open
Nobody has claimed this yet.
Bug
Status: Needs Triage
- Dominant language
- C
- Stars
- 40.4k
- Forks
- 8.1k
- Avg merge
- 2d 13h
- Merged PRs (30d)
- 96
Description
Description
The following code:
<?php
ob_start(function ($buffer) {
// return '';
throw new \Exception('x');
});
echo 5;
try {
ob_flush();
} catch (\Exception $e) {
echo $e;
}
Expected output:
-5Exception: x in /in/kQMfY:5
+Exception: x in /in/kQMfY:5
Stack trace:
#0 [internal function]: {closure}('5', 5)
#1 /in/kQMfY(11): ob_flush()
#2 {main}
PHP Version
any
Operating System
any
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by running the provided PHP reproduction for ob_start and ob_flush, then compare its output with the expected output and the linked 3v4l example. Trace the output-buffer callback exception path in php-src and verify that the buffered value 5 is not printed when the callback throws; the work is done when this behavior is covered by a regression test.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- c, php
- Domain
- backend
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 45/100