php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #79114 Eval class during preload causes class to be only half available
Submitted: 2020-01-14 11:50 UTC Modified: 2020-01-17 11:36 UTC
From: beberlei@php.net Assigned:
Status: Closed Package: opcache
PHP Version: 7.4.1 OS: Linux
Private report: No CVE-ID: None
View Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
MUST BE VALID
Solve the problem:
1 + 2 = ?
Subscribe to this entry?

 
 [2020-01-14 11:50 UTC] 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


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2020-01-17 11:36 UTC] nikic@php.net
-Status: Open +Status: Verified
 [2020-01-20 04:29 UTC] laruence@php.net
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)
 [2020-01-20 04:29 UTC] laruence@php.net
-Status: Verified +Status: Closed
 
PHP Copyright © 2001-2020 The PHP Group
All rights reserved.
Last updated: Wed May 27 12:01:27 2020 UTC