note 124597 added to function.virtual
| From: | php at nagler-ihlein dot de | Date: | Fri, 10 Jan 2020 13:22:31 +0000 |
| Subject: | note 124597 added to function.virtual | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-213837@lists.php.net to get a copy of this message | ||
Starting with 7.2 various session related things were changed and it seems part of it is conflicting
with virtual(). Calling it you may receive a "PHP Warning: virtual(): Headers already sent.
You cannot change the session module's ini settings at this time in ..." although no
header was set and virtual() should simply provide static content from a file.
It took half a day to find out that some main session.configuration.php settings (e.g. save_handler,
serialize_handler, or save_path) in the Apache config (all levels) are causing this. It seems the
settings are regarded as likely to change headers but virtual() is already beyond sending them.
Unfortunately the warning is then not only logged to error_log but also part of the content
virtual() sends to the client which screws it up - the format of the content like binary image data
is no more correct.
If you do not need php's session management you can remove all session.* settings in your
apache configuration to avoid the warning. Otherwise a workaround is to switch off E_WARNING before
calling virtual().
<?php
$filename = '/data/image.jpg';
$level = error_reporting();
error_reporting($level & ~E_WARNING);
virtual($filename);
error_reporting($level);
?>
----
Server IP: 45.112.84.4
Probable Submitter: 103.51.167.36 (proxied: 185.35.208.129)
----
Manual Page -- http://php.net/manual/en/function.virtual.php
Edit -- https://master.php.net/note/edit/124597
Del: integrated -- https://master.php.net/note/delete/124597/integrated
Del: useless -- https://master.php.net/note/delete/124597/useless
Del: bad code -- https://master.php.net/note/delete/124597/bad+code
Del: spam -- https://master.php.net/note/delete/124597/spam
Del: non-english -- https://master.php.net/note/delete/124597/non-english
Del: in docs -- https://master.php.net/note/delete/124597/in+docs
Del: other reasons-- https://master.php.net/note/delete/124597
Reject -- https://master.php.net/note/reject/124597
Search -- https://master.php.net/manage/user-notes.php