[php-src] PHP-8.6: Merge branch 'PHP-8.5' into PHP-8.6

From: Date: Sat, 31 Oct 2026 06:30:55 +0000
Subject: [php-src] PHP-8.6: Merge branch 'PHP-8.5' into PHP-8.6
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-143047@lists.php.net to get a copy of this message
Author: David Carlier (devnexen) Date: 2026-10-31T06:30:32Z Commit: https://github.com/php/php-src/commit/8b7ab3787304f85e7886a87a876ba3a0e618ee7d Raw diff: https://github.com/php/php-src/commit/8b7ab3787304f85e7886a87a876ba3a0e618ee7d.diff Merge branch 'PHP-8.5' into PHP-8.6 * PHP-8.5: Fix GH-24534: inheritance cache records unlinked child dependencies Changed paths: A ext/opcache/tests/gh24534.phpt M Zend/zend_inheritance.c Diff: diff --git a/Zend/zend_inheritance.c b/Zend/zend_inheritance.c index ba9d2387201f..5a11a5d8bd8b 100644 --- a/Zend/zend_inheritance.c +++ b/Zend/zend_inheritance.c @@ -400,7 +400,7 @@ static void track_class_dependency(zend_class_entry *ce, zend_string *class_name ht = (HashTable*)CG(current_linking_class)->inheritance_cache; - if (!(ce->ce_flags & ZEND_ACC_IMMUTABLE)) { + if (!(ce->ce_flags & ZEND_ACC_IMMUTABLE) || !(ce->ce_flags & ZEND_ACC_LINKED)) { // TODO: dependency on not-immutable class ??? if (ht) { zend_hash_destroy(ht); diff --git a/ext/opcache/tests/gh24534.phpt b/ext/opcache/tests/gh24534.phpt new file mode 100644 index 000000000000..99dad3386623 --- /dev/null +++ b/ext/opcache/tests/gh24534.phpt @@ -0,0 +1,95 @@ +--TEST-- +GH-24534: Inheritance cache must not record an unlinked child as a dependency +--CREDITS-- +Wim Winterberg +--EXTENSIONS-- +opcache +--CONFLICTS-- +server +--FILE-- +<?php +$dir = __DIR__ . '/gh24534'; +@mkdir($dir . '/src', 0777, true); + +file_put_contents($dir . '/autoload.php', <<<'PHP' +<?php +spl_autoload_register(static function (string $class): void { + $file = __DIR__ . '/src/' . $class . '.php'; + if (is_file($file)) { + require $file; + } +}); +PHP); + +file_put_contents($dir . '/src/EntityInterface.php', <<<'PHP' +<?php +interface EntityInterface +{ + public static function getById(int $id): ?self; +} +PHP); + +file_put_contents($dir . '/src/Entity.php', <<<'PHP' +<?php +abstract class Entity implements EntityInterface +{ + protected array $data = []; +} +PHP); + +file_put_contents($dir . '/src/UserBase.php', <<<'PHP' +<?php +abstract class UserBase extends Entity +{ + public const TABLE = 'user'; + + protected ?int $userId = null; + + public static function getById(int $id): ?User + { + return null; + } +} +PHP); + +file_put_contents($dir . '/src/User.php', <<<'PHP' +<?php +class User extends UserBase +{ +} +PHP); + +file_put_contents($dir . '/base-first.php', <<<'PHP' +<?php +require __DIR__ . '/autoload.php'; +echo 'base-first: ', UserBase::TABLE, PHP_EOL; +PHP); + +file_put_contents($dir . '/child-first.php', <<<'PHP' +<?php +require __DIR__ . '/autoload.php'; +echo 'child-first: ', User::TABLE, PHP_EOL; +PHP); + +include 'php_cli_server.inc'; +$ini = trim((string) getenv('TEST_PHP_EXTRA_ARGS')); +$ini .= ($ini !== '' ? ' ' : '') . '-d opcache.enable=1 -d opcache.enable_cli=1 -d opcache.file_update_protection=0'; +php_cli_server_start($ini); + +foreach (['base-first', 'child-first', 'base-first'] as $page) { + echo file_get_contents('http://' . PHP_CLI_SERVER_ADDRESS . '/gh24534/' . $page . '.php'); +} +?> +--CLEAN-- +<?php +$dir = __DIR__ . '/gh24534'; +foreach (['src/EntityInterface.php', 'src/Entity.php', 'src/UserBase.php', 'src/User.php', 'autoload.php', 'base-first.php', 'child-first.php'] as $file) { + @unlink($dir . '/' . $file); +} +@rmdir($dir . '/src'); +@rmdir($dir); +?> +--EXPECT-- +base-first: user +child-first: user +base-first: user

« previous php.cvs (#143047) next »