php / php/php-src

Apache virtual() failures with session module

Đang mở
#17,655 2 bình luận 0 reaction 0 người được giao Xem trên GitHub

Chưa có ai nhận issue này.

Bug Extension: session SAPI: apache2handler
Ngôn ngữ chính
C
Star
40.4k
Fork
8.1k
Merge trung bình
2 ngày 13 giờ
Pull request đã merge (30 ngày)
96

Mô tả

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

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Hướng nghiên cứu

Tái hiện virtual() với các thiết lập session.* được mô tả trong cấu hình Apache, sau đó kiểm tra các đường dẫn của virtual() và session-module xung quanh SG(headers_sent) và các biến toàn cục dùng chung. Xác nhận liệu trạng thái dành riêng cho session có đang được tái sử dụng hoặc khôi phục không chính xác hay không. Hoàn tất khi cảnh báo không còn bị chèn vào đầu ra của virtual(), nội dung nhị phân vẫn nguyên vẹn và hành vi liên quan đã được kiểm thử.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Đánh giá

Công nghệ
apache, c, php
Lĩnh vực
backend
Loại issue
Lỗi
Độ khó
4/5
Thời gian dự kiến
3-5 ngày
Mức độ hoạt động
Đình trệ
Độ rõ ràng
Khá rõ ràng
Mức phù hợp với người mới
35/100

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.