From: problembug at speed dot 1s dot fr
Operating system: Linux
PHP version: 7.4.13
Package: Apache related
Bug Type: Bug
Bug description:Apache ErrorDocument subrequest fails horribly
Description:
------------
Reproducible on Amazon Linux, Slackware and others with various
combinations of (recent) PHP and Apache. When httpd.conf is configured
with an ErrorDocument to a PHP script and an error is deliberately
introduced with a faulty header, the mere presence of a flush() changes
the graceful error handling (via a subrequest) in to a confusing and
bizarre situation that introduces secondary bugs.
These include:
o PHP no longer honours previous require_once include guard
o Apache not sending back any output to the client
o Misleading messages in the PHP error log about other modules
o Misleading messages in the PHP error log about ini_set (?) which is
never used
o PHP error log messages repeated multiple times
The presence of a single flush() changes the graceful error handling
($test = 2) in to a confusing mess ($test = 3) and introduces seemingly
unrelated bugs.
Steps to reproduce:
1. Edit an Apache VirtualHost config in to include the following:
ErrorDocument 500 /error.php
2. Place the 3 attached scripts in the VirtualHost's DocumentRoot:
test.php error.php library.php
3. Restart Apache
4. Access https://somesite/test.php
5. Alter test.php to try $test = 2 and $test = 3
6. Observe all the unexpected and secondary problems the flush()
introduces
Test script:
---------------
https://pastebin.com/MBQEEb5Q
Expected result:
----------------
Expected result for test 3 is same as test 2:
----
PHP error log:
No new entries.
----
$ curl -i https://somesite/test.php
HTTP/1.1 500 Internal Server Error
Date: Sun, 27 Dec 2020 14:05:47 GMT
Server: Apache
Content-Type: text/html; charset=UTF-8
I will deal with a 500 error and show a pretty error message
Actual result:
--------------
Actual result for test 3:
----
PHP error log:
[27-Dec-2020 13:49:41 UTC] PHP Warning: flush(): Headers already sent.
You cannot change the session module's ini settings at this time in
/www/test.php on line 22
[27-Dec-2020 13:49:41 UTC] PHP Warning: flush(): Headers already sent.
You cannot change the session module's ini settings at this time in
/www/test.php on line 22
[27-Dec-2020 13:49:41 UTC] PHP Warning: flush(): Headers already sent.
You cannot change the session module's ini settings at this time in
/www/test.php on line 22
[27-Dec-2020 13:49:41 UTC] PHP Warning: flush(): Headers already sent.
You cannot change the session module's ini settings at this time in
/www/test.php on line 22
[27-Dec-2020 13:49:41 UTC] PHP Fatal error: Cannot redeclare foo()
(previously declared in /www/library.php:4) in /www/library.php on line
4
----
$ curl -i https://somesite/test.php
curl: (52) Empty reply from server
--
Edit bug report at https://bugs.php.net/bug.php?id=80558&edit=1
--
Fix committed: https://bugs.php.net/fix.php?id=80558&r=fixed
Fixed in release: https://bugs.php.net/fix.php?id=80558&r=alreadyfixed
Need backtrace: https://bugs.php.net/fix.php?id=80558&r=needtrace
Need Reproduce Script: https://bugs.php.net/fix.php?id=80558&r=needscript
Try newer version: https://bugs.php.net/fix.php?id=80558&r=oldversion
Not developer issue: https://bugs.php.net/fix.php?id=80558&r=support
Expected behavior: https://bugs.php.net/fix.php?id=80558&r=notwrong
Not enough info: https://bugs.php.net/fix.php?id=80558&r=notenoughinfo
Submitted twice: https://bugs.php.net/fix.php?id=80558&r=submittedtwice
register_globals: https://bugs.php.net/fix.php?id=80558&r=globals
PHP version support discontinued: https://bugs.php.net/fix.php?id=80558&r=phptooold
Daylight Savings: https://bugs.php.net/fix.php?id=80558&r=dst
IIS Stability: https://bugs.php.net/fix.php?id=80558&r=isapi
Install GNU Sed: https://bugs.php.net/fix.php?id=80558&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=80558&r=float
No Zend Extensions: https://bugs.php.net/fix.php?id=80558&r=nozend
MySQL Configuration Error: https://bugs.php.net/fix.php?id=80558&r=mysqlcfg