Bug #78495 [NEW]: Allow any functions in ob_start user's callback

From: Date: Thu, 05 Sep 2019 12:34:35 +0000
Subject: Bug #78495 [NEW]: Allow any functions in ob_start user's callback
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-222569@lists.php.net to get a copy of this message
From: michael dot vorisek at email dot cz Operating system: Any PHP version: 7.3.9 Package: Output Control Bug Type: Bug Bug description:Allow any functions in ob_start user's callback Description: ------------ Currently the ob_start user's callback is executed in some special context and (at least) these functions behave not as expected: - ob_end_clean - exit The "ob_end_clean" is not supported as "Cannot use output buffering in output buffering display handlers". But the "exit" should be fully supported as there is no other way to interrupt the code execution and get shutdown handlers executed. Obviously the shutdown handlers should be able to output some data or manipulate with the output buffering. The desired execution flow be the following: standard code... -- ob handler called ---- stop ob handler execution if an exception is thrown or exit is called -- exit the ob handler context and - if an exception was thrown handle the exception as uncaught in global context and - exit the main execution, i.e. start processing shutdown handlers as if normal exit was called (if no exit was called yet) Test script: --------------- <?php // capture any unexpected output and exit execution ob_start(function($buffer) { ob_end_clean(); echo 'unexpected output: ' . $buffer . "\n"; exit; }, 1); // do some work on shutdown register_shutdown_function(function() { echo 'shutting down'; }); echo 'test_1'; echo 'test_2'; Expected result: ---------------- Fatal error: ob_end_clean(): Cannot use output buffering in output buffering display handlers in C:\Users\mvorisek\Desktop\x.php on line 5 shutting down Actual result: -------------- unexpected output: test_1 shutting down -- Edit bug report at https://bugs.php.net/bug.php?id=78495&edit=1 -- Fix committed: https://bugs.php.net/fix.php?id=78495&r=fixed Fixed in release: https://bugs.php.net/fix.php?id=78495&r=alreadyfixed Need backtrace: https://bugs.php.net/fix.php?id=78495&r=needtrace Need Reproduce Script: https://bugs.php.net/fix.php?id=78495&r=needscript Try newer version: https://bugs.php.net/fix.php?id=78495&r=oldversion Not developer issue: https://bugs.php.net/fix.php?id=78495&r=support Expected behavior: https://bugs.php.net/fix.php?id=78495&r=notwrong Not enough info: https://bugs.php.net/fix.php?id=78495&r=notenoughinfo Submitted twice: https://bugs.php.net/fix.php?id=78495&r=submittedtwice register_globals: https://bugs.php.net/fix.php?id=78495&r=globals PHP version support discontinued: https://bugs.php.net/fix.php?id=78495&r=phptooold Daylight Savings: https://bugs.php.net/fix.php?id=78495&r=dst IIS Stability: https://bugs.php.net/fix.php?id=78495&r=isapi Install GNU Sed: https://bugs.php.net/fix.php?id=78495&r=gnused Floating point limitations: https://bugs.php.net/fix.php?id=78495&r=float No Zend Extensions: https://bugs.php.net/fix.php?id=78495&r=nozend MySQL Configuration Error: https://bugs.php.net/fix.php?id=78495&r=mysqlcfg

« previous php.bugs (#222569) next »