Bug #79446 [Opn->Nab]: Flush() is needed to print headers when execution is terminated

From: Date: Tue, 07 Apr 2020 18:47:45 +0000
Subject: Bug #79446 [Opn->Nab]: Flush() is needed to print headers when execution is terminated
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-226469@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=79446&edit=1 ID: 79446 Updated by: requinix@php.net Reported by: michael dot vorisek at email dot cz Summary: Flush() is needed to print headers when execution is terminated -Status: Open +Status: Not a bug Type: Bug Package: Scripting Engine problem PHP Version: 7.4.4 Block user comment: N Private report: N New Comment: Okay? Previous Comments: ------------------------------------------------------------------------ [2020-04-07 17:18:29] michael dot vorisek at email dot cz Close this ------------------------------------------------------------------------ [2020-04-03 12:37:03] michael dot vorisek at email dot cz Description: ------------ For some reasons headers are not outputted when script is terminated with set_exception_handler(). I was not able to isolate the issue, simple test below does not have it, but the complex example below is repeatable across multiple servers and PHP versions (7.2 - 7.4.4). Test script: --------------- # this works even without flush() header('Content-Type: application/json', true); echo json_encode('test'); // flush(); set_exception_handler(function (Throwable $t) {return true;}); throw new \Exception(); # but in this code flush() is required, otherwise "text/html; charset=UTF-8" is outputted even if this exact content-type (with charset) is not outputted in this project at at (it has to come from PHP) https://github.com/atk4/ui/pull/1051/commits/423251f13e515a0dadaed548abe17989cfbf0f33#diff-58980ac23a3a9a0b92abd9805eed1e78R227 CI results prior fixing with flush(): https://github.com/atk4/ui/runs/556304096?check_suite_focus=true#step:9:50 It can be easily reproduced locally when you clone https://github.com/mvorisek/atk4_ui/commit/46411692933745ef7b715c608363393afc803b85 and open URL ./demos/sticky2.php?__atk_reload=atk_admin_button . Issue can be reproduced with fast-cgi and internal php web server. Expected result: ---------------- Headers, ie. content-type in the example, are always sent even if the execution is immediatelly terminated. Actual result: -------------- Headers are not outputed. ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=79446&edit=1

« previous php.bugs (#226469) next »