Opcache does not handle class hoisting with @opcache_compile_file
Dieses Issue hat noch niemand übernommen.
- Vorherrschende Sprache
- C
- Sterne
- 40.4k
- Forks
- 8.2k
- Ø Merge
- 2 T. 13 Std.
- Gemergte PRs (30 T.)
- 96
Beschreibung
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
Beitragsleitfaden
Erste Schritte
- Lies das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreib ins Issue, dass du es übernimmst — das erspart doppelte Arbeit.
- Forke das Repository und arbeite in einem Branch.
- Öffne einen Pull Request, der die Issue-Nummer nennt.
Rechercherichtung
Beginne damit, das Verhalten mit der test.php und exec.php des Issues unter PHP 8.1.32 zu reproduzieren, und verfolge anschließend, wie OPcache opcache_compile_file und das Hoisting von Klassen behandelt. Die Aufgabe ist erledigt, wenn das Einbinden der kompilierten test.php keinen HelloWorld-Fehler mehr auslöst und das Szenario mit dem WordPress-Autoloader korrekt funktioniert.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Bewertung
- Tech-Stack
- php
- Bereich
- backend
- Issue-Typ
- Bug
- Schwierigkeit
- 4/5
- Geschätzter Aufwand
- 3-5 Tage
- Aktivitätsstatus
- Veraltet
- Klarheit
- Größtenteils klar
- Anfängerfreundlichkeit
- 35/100