Bug #78565 [Com]: Shutdown functions are not called when exit is called from output handler
Edit report at https://bugs.php.net/bug.php?id=78565&edit=1
ID: 78565
Comment by: video dot ice dot power at seznam dot cz
Reported by: video dot ice dot power at seznam dot cz
Summary: Shutdown functions are not called when exit is
called from output handler
Status: Open
Type: Bug
Package: *General Issues
Operating System: Debian 9
PHP Version: 7.3.9
Block user comment: N
Private report: N
New Comment:
The issue is also in PHP 7.3 and 7.4, only the result is different.
Handler of ob_start should be called without any limitation and the output should be handled once
the handler ends.
Previous Comments:
------------------------------------------------------------------------
[2021-04-06 21:38:12] cmb@php.net
Well, yes, for PHP 8.0, but you specified that this is about PHP
7.3.9.
------------------------------------------------------------------------
[2021-04-06 19:21:10] video dot ice dot power at seznam dot cz
https://3v4l.org/ZoBJs - "shutting down" text is not
printed
------------------------------------------------------------------------
[2021-04-06 17:11:26] cmb@php.net
I cannot reproduce this; I get (PHP-7.3 and -7.4 on Windows, and
PHP-7.4 on Debian):
Fatal error: ob_flush(): Cannot use output buffering in output buffering display handlers
So, apparently, the shutdown handler is executed. What am I
missing?
------------------------------------------------------------------------
[2019-12-17 18:25:57] archon810 at gmail dot com
We've been trying to figure out why Sentry doesn't fire in AMP and arrived at the same
conclusion - lack of the register_shutdown_function call when in ob_, which is used by AMP.
Please see https://github.com/getsentry/sentry-php/issues/927
and https://github.com/ampproject/amp-wp/issues/3825.
If any PHP core devs would chime in, that'd be great.
Thank you.
------------------------------------------------------------------------
[2019-09-19 07:41:42] video dot ice dot power at seznam dot cz
Description:
------------
Shutdown functions are not called when exit is called from output handler
Test script:
---------------
<?php
// capture any unexpected output and exit execution
ob_start(function($buffer) {
echo 'unexpected output: ' . $buffer . "\n";
exit;
}, 1);
// do some work on shutdown
register_shutdown_function(function() {
ob_flush();
ob_end_clean();
echo 'shutting down';
});
echo 'x';
Expected result:
----------------
unexpected output: x
shutting down
Actual result:
--------------
(empty result)
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=78565&edit=1
Thread (7 messages)