[2020年06月19日 17:48 UTC] brianlmoon@php.net
Description: ------------ When a request has no output (a redirect or 204 no content for example), or the request method is HEAD (even if the request would have generated output normally), autoloading inside the callback provided to header_register_callback fails. For requests with output, autoloading works as expected. Test script: --------------- <?php error_reporting(-1); ini_set("display_errors", true); header("Location: /foo"); header("X-Bar: 2"); spl_autoload_register(function($class) { include __DIR__."/Foo.php"; }); header_register_callback(function() { header("X-Baz: 3"); header("X-Foo: ".Foo::BAR); }); if(!empty($_GET["output"])) { echo "test"; } /* Foo.php <?php class Foo { const BAR = 1; } */ Expected result: ---------------- The following headers are returned for all requests regardless if there is output or not. X-Bar: 2 X-Baz: 3 X-Foo: 1 For example, with output: < HTTP/1.1 302 Found < Server: nginx/1.17.10 < Date: 2020年6月19日 17:45:39 GMT < Content-Type: text/html; charset=UTF-8 < Transfer-Encoding: chunked < Connection: keep-alive < Location: /foo < X-Bar: 2 < X-Baz: 3 < X-Foo: 1 < Strict-Transport-Security: max-age=31536000; includeSubdomains < * Connection #0 to host labs.moonspot.net left intact test Actual result: -------------- < HTTP/1.1 302 Found < Server: nginx/1.17.10 < Date: 2020年6月19日 17:46:28 GMT < Content-Type: text/html; charset=UTF-8 < Transfer-Encoding: chunked < Connection: keep-alive < Location: /foo < X-Bar: 2 < X-Baz: 3 < Strict-Transport-Security: max-age=31536000; includeSubdomains < <br /> <b>Fatal error</b>: Uncaught Error: Class 'Foo' not found in /xxx/public/test.php:16 Stack trace: #0 [internal function]: {closure}() #1 {main} thrown in <b>/xxx/public/test.php</b> on line <b>16</b><br /> PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2020年06月19日 18:04 UTC] requinix@php.net
[2020年10月10日 00:02 UTC] gtisza at wikimedia dot org
|