Opcache does not handle class hoisting with @opcache_compile_file
オープン
まだ誰も着手していません。
Bug
Extension: opcache
Status: Verified
- 主要言語
- C
- スター
- 40.4k
- フォーク
- 8.2k
- 平均マージ
- 2日 13時間
- マージ済み PR(30日)
- 96
説明
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
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
調査の方向性
まず PHP 8.1.32 を使用して、issue の test.php と exec.php で動作を再現し、その後、OPcache が opcache_compile_file とクラスのホイスティングをどのように処理するかを追跡します。コンパイル済みの test.php を require しても HelloWorld エラーが発生せず、WordPress のオートローダーのシナリオが正しく動作すれば完了です。
索引モデルが issue の本文から書いたものです。
評価
- 技術スタック
- php
- 領域
- backend
- issue の種類
- バグ
- 難易度
- 4/5
- 見積もり時間
- 3〜5日
- 活発さ
- 停滞
- 明瞭さ
- おおむね明確
- 初心者へのやさしさ
- 35/100