Bug #78565 [Fbk->Opn]: Shutdown functions are not called when exit is called from output handler

From: Date: Tue, 06 Apr 2021 21:38:12 +0000
Subject: Bug #78565 [Fbk->Opn]: Shutdown functions are not called when exit is called from output handler
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-233273@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=78565&edit=1

 ID:                 78565
 Updated by:         cmb@php.net
 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:             Feedback
+Status:             Open
 Type:               Bug
 Package:            *General Issues
 Operating System:   Debian 9
 PHP Version:        7.3.9
-Assigned To:        cmb
+Assigned To:        
 Block user comment: N
 Private report:     N

 New Comment:

Well, yes, for PHP 8.0, but you specified that this is about PHP
7.3.9.


Previous Comments:
------------------------------------------------------------------------
[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)

« previous php.bugs (#233273) next »