Apache virtual() failures with session module
还没有人认领这个 Issue。
- 主要语言
- C
- 星标
- 40.4k
- 派生
- 8.1k
- 平均合并
- 2 天 13 小时
- 30 天内合并 PR
- 96
描述
Description
This is taken from the note in docs: https://www.php.net/manual/en/function.virtual.php#124597
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);
?>
This will be most likely related sharing of globals and will require some restoring of parent globals like. It needs more checking if it's just for SG(headers_sent) or some session globals as well. In general, there are likely more issue with re-using globals in this way so this might probably need some deeper review. I guess it would be still worth to fix the session specific issues and do a bit more testing to see if more generic approach makes sense.
PHP Version
PHP 8.3+
Operating System
No response
贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
调研方向
使用 Apache 配置中描述的 session.* 设置重现 virtual(),然后检查 SG(headers_sent) 和共享全局变量周围的 virtual() 与 session-module 路径。确认特定于 session 的状态是否被重复使用或错误地恢复。完成标准是:警告不再被注入 virtual() 的输出,二进制内容保持完整,并且相关行为已通过测试。
由索引模型根据 Issue 内容生成。
评估
- 技术栈
- apache, c, php
- 领域
- backend
- Issue 类型
- 缺陷
- 难度
- 4/5
- 预计耗时
- 3-5 天
- 活跃度
- 停滞
- 描述清晰度
- 基本清楚
- 新手友好度
- 35/100