[php-src] Issue #21411: opcache_compile_file() fails to early-bind classes without parents

[email protected] (rlerdorf)
Newsgroups php.bugs
Message-ID <[email protected]>
Issue: https://github.com/php/php-src/issues/21411
Author: rlerdorf

### Description

The following code:

test.inc:
```php
<?php
echo NoParentClass::VALUE . "\n";
class NoParentClass {
    const VALUE = "hello";
}
```

Compiled and loaded via opcache file cache:
```php
<?php
// Step 1: Compile into file cache
opcache_compile_file('/path/to/test.inc');

// Step 2: In a separate process, include from file cache
include '/path/to/test.inc';
```

With INI settings:
```
opcache.enable=1
opcache.enable_cli=1
opcache.file_cache=/tmp/cache
opcache.file_cache_only=1
opcache.file_update_protection=0
```

Resulted in this output:
```
Fatal error: Uncaught Error: Class "NoParentClass" not found in /path/to/test.inc:2
Stack trace:
#0 Command line code(1): include()
#1 {main}
  thrown in /path/to/test.inc on line 2
```

But I expected this output instead:
```
hello
```

### PHP Version

```plain
This affects versions 8.3+ because https://github.com/php/php-src/commit/0600f513b374969992f86591ad9834a32df319a8, which implemented delayed early binding for classes without parents, did not take into account that `opcache_compile_file()` produces unlinked classes with an empty-string `lc_parent_name`, causing `zend_accel_do_delayed_early_binding() to` skip early binding for these classes when loading them from cache.
```

### Operating System

_No response_
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.