Opcache does not handle class hoisting with @opcache_compile_file
Chưa có ai nhận issue này.
- 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
The following code:
// test.php
<?php
$x = new HelloWorld();
class HelloWorld {}
// exec.php
<?php
@opcache_compile_file(__DIR__.'/test.php');
require_once __DIR__.'/test.php';
When I ran php exec.php it
Resulted in this output:
[30-May-2025 08:10:33 UTC] PHP Fatal error: Uncaught Error: Class "HelloWorld" not found in /usr/src/wordpress/wp-includes/SimplePie/test.php:3
Stack trace:
#0 /usr/src/wordpress/wp-includes/SimplePie/exec.php(3): require_once()
#1 {main}
thrown in /usr/src/wordpress/wp-includes/SimplePie/test.php on line 3
But I expected this output instead:
empty as it does not return anything
When just running test.php it runs successfully.
This causes an error in Wordpress file /usr/src/wordpress/wp-includes/SimplePie/autoloader.php when we use Opcache preloading preventing it from working properly.
PHP Version
PHP 8.1.32 (cli) (built: Apr 29 2025 20:07:59) (NTS)
Copyright (c) The PHP Group
Zend Engine v4.1.32, Copyright (c) Zend Technologies
with Zend OPcache v8.1.32, Copyright (c), by Zend Technologies
Operating System
No response
Hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- 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.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Hướng nghiên cứu
Bắt đầu bằng cách tái hiện hành vi với test.php và exec.php của issue bằng PHP 8.1.32, sau đó theo dõi cách OPcache xử lý opcache_compile_file và việc hoisting class. Hoàn tất khi việc require test.php đã biên dịch không còn gây ra lỗi HelloWorld và kịch bản autoloader của WordPress hoạt động chính xác.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Đánh giá
- Công nghệ
- 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