[php-src] Issue #7957: Shutdown functions are not called when exit is called from output handler

From: Date: Mon, 17 Jan 2022 10:25:44 +0000
Subject: [php-src] Issue #7957: Shutdown functions are not called when exit is called from output handler
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-239058@lists.php.net to get a copy of this message
Issue: https://github.com/php/php-src/issues/7957
Author: mvorisek

### Description

Original report https://bugs.php.net/bug.php?id=78565

The following code:

```php
<?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';
```

Resulted in this output:
```
xunexpected output: x
unexpected output: 
```

But I expected this output instead:
```
unexpected output: x
shutting down
```


### PHP Version

8.0+

### Operating System

any


Thread (1 message)

  • mvorisek
« previous php.bugs (#239058) next »