Bug #79114 [Ver->Csd]: Eval class during preload causes class to be only half available

From: Date: Mon, 20 Jan 2020 04:29:41 +0000
Subject: Bug #79114 [Ver->Csd]: Eval class during preload causes class to be only half available
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-224997@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=79114&edit=1 ID: 79114 Updated by: laruence@php.net Reported by: beberlei@php.net Summary: Eval class during preload causes class to be only half available -Status: Verified +Status: Closed Type: Bug Package: opcache Operating System: Linux PHP Version: 7.4.1 Block user comment: N Private report: N New Comment: Automatic comment on behalf of laruence@gmail.com Revision: http://git.php.net/?p=php-src.git;a=commit;h=9c2fd55d015b792c609e43a334809a2239267b6d Log: Fixed bug #79114 (Eval class during preload causes class to be only half available) Previous Comments: ------------------------------------------------------------------------ [2020-01-14 11:50:58] beberlei@php.net Description: ------------ IF you eval a class during preload, you cannot instantiate it, but you can extend from it and class_parents shows its as parent. Test script: --------------- // index.php <?php var_dump(class_exists(Foo::class)); var_dump(class_exists(Bar::class)); ini_set('display_errors', true); var_dump(new Bar()); var_dump(class_parents('Bar')); var_dump(new Foo()); // preload.php <?php eval("class Foo {}"); class Bar extends Foo { } Expected result: ---------------- bool(false) bool(true) object(Bar)#1 (0) { } array(1) { ["Foo"]=> string(3) "Foo" } object(Foo)#2 (0) { } Actual result: -------------- bool(false) bool(true) object(Bar)#1 (0) { } array(1) { ["Foo"]=> string(3) "Foo" } Fatal error: Uncaught Error: Class 'Foo' not found in /var/www/preload/index.php:10 Stack trace: #0 /home/benny/.symfony/php/a37c6f52bd8b76a9d0374711bf78143b455254a2-router.php(29): require() #1 {main} thrown in /var/www/preload/index.php on line 10 ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=79114&edit=1

« previous php.bugs (#224997) next »