com php-src: Allow unlinked classes when performing in_compilation variance check: Zend/zend_inheritanc e.c ext/opcache/tests/preload_variance.inc

From: Date: Tue, 03 Nov 2020 13:49:10 +0000
Subject: com php-src: Allow unlinked classes when performing in_compilation variance check: Zend/zend_inheritanc e.c ext/opcache/tests/preload_variance.inc
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-114049@lists.php.net to get a copy of this message
Commit: 7e5531755812a46841fc24ade5f71aefde69cf96 Author: Nikita Popov <nikita.ppv@gmail.com> Tue, 3 Nov 2020 14:49:10 +0100 Parents: ee934f8245b58e1a557ed7b3f303f2d9d7cd23a6 Branches: PHP-8.0 master Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=7e5531755812a46841fc24ade5f71aefde69cf96 Log: Allow unlinked classes when performing in_compilation variance check As preloading runs in in_compilation mode, we also need to allow use of unlinked classes in lookup_class(). Changed paths: M Zend/zend_inheritance.c M ext/opcache/tests/preload_variance.inc Diff: diff --git a/Zend/zend_inheritance.c b/Zend/zend_inheritance.c index 34489938a92..c3aad9f614c 100644 --- a/Zend/zend_inheritance.c +++ b/Zend/zend_inheritance.c @@ -239,10 +239,9 @@ static zend_bool class_visible(zend_class_entry *ce) { static zend_class_entry *lookup_class( zend_class_entry *scope, zend_string *name, zend_bool register_unresolved) { - zend_class_entry *ce; + uint32_t flags = ZEND_FETCH_CLASS_ALLOW_UNLINKED | ZEND_FETCH_CLASS_NO_AUTOLOAD; + zend_class_entry *ce = zend_lookup_class_ex(name, NULL, flags); if (!CG(in_compilation)) { - uint32_t flags = ZEND_FETCH_CLASS_ALLOW_UNLINKED | ZEND_FETCH_CLASS_NO_AUTOLOAD; - ce = zend_lookup_class_ex(name, NULL, flags); if (ce) { return ce; } @@ -256,7 +255,6 @@ static zend_class_entry *lookup_class( zend_hash_add_empty_element(CG(delayed_autoloads), name); } } else { - ce = zend_lookup_class_ex(name, NULL, ZEND_FETCH_CLASS_NO_AUTOLOAD); if (ce && class_visible(ce)) { return ce; } diff --git a/ext/opcache/tests/preload_variance.inc b/ext/opcache/tests/preload_variance.inc index eae3cd71526...85e569f3455 100644 --- a/ext/opcache/tests/preload_variance.inc +++ b/ext/opcache/tests/preload_variance.inc @@ -14,11 +14,13 @@ class C extends Z { public function method($a): self {} public function method2($a): C {} public function method3($a): object {} + public function method4(D $a) {} } class D extends C { public function method($a): self {} public function method2($a): D {} public function method3($a): stdClass {} + public function method4(C $a) {} } // Works.

« previous php.cvs (#114049) next »