[php-src] Issue #11375: headers_sent(&$filename, &$linenum) returns true and yet doesn't set either filename or linenum
| From: | php4fan | Date: | Mon, 05 Jun 2023 19:56:51 +0000 |
| Subject: | [php-src] Issue #11375: headers_sent(&$filename, &$linenum) returns true and yet doesn't set either filename or linenum | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-244604@lists.php.net to get a copy of this message | ||
Issue: https://github.com/php/php-src/issues/11375
Author: php4fan
From manual page: https://php.net/function.headers-sent
---
It says:
> If the optional filename and line parameters are set, headers_sent() will put the PHP source
> file name and line number where output started in the filename and line variables.
Therefore, if I call
headers_sent($filename, $linenum) and pass it both arguments, and
it returns true, I expect it to set both filename and linenum to the file
and line number where the output started.
And yet, I (pretty often) observe cases where it returns true and yet doesn't set filename and
line number. I don't know how to reproduce, because, because of the very fact that it
doesn't tell me where the output started, I have been unable to debug it. Otherwise I would be
happy to provide example code that reproduces.
If there are legitimate cases for headers_sent() being unable to tell the file name and
line number where the output started, then these cases should be documented in excruciating detail.
But I can't think of any such legitimate cases. My script is initiated by a php file, so
wherever the output started, that "somewhere" MUST be at least backtraceable to some
filename and line number (if it was started by eval()'d code, then it's the filename and
line number that called eval(), that is given that you decided that only a filename and line number
are to be returned and not a backtrace of any sort).