php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #78565 Shutdown functions are not called when exit is called from output handler
Submitted: 2019-09-19 07:41 UTC Modified: -
From: video dot ice dot power at seznam dot cz Assigned:
Status: Open Package: *General Issues
PHP Version: 7.3.9 OS: Debian 9
Private report: No CVE-ID: None
View Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please — but make sure to vote on the bug!
Your email address:
MUST BE VALID
Solve the problem:
23 - 5 = ?
Subscribe to this entry?

 
 [2019-09-19 07:41 UTC] 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)

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2019-12-17 18:25 UTC] 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.
 
PHP Copyright © 2001-2020 The PHP Group
All rights reserved.
Last updated: Wed Nov 25 09:01:23 2020 UTC