php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #64353 Built-in classes can be unavailable with dynamic includes and Optimizer+
Submitted: 2013-03-05 06:50 UTC Modified: 2013-03-05 11:00 UTC
Votes:2
Avg. Score:4.5 ± 0.5
Reproduced:2 of 2 (100.0%)
Same Version:2 (100.0%)
Same OS:1 (50.0%)
From: lisachenko dot it at gmail dot com Assigned: dmitry (profile)
Status: Closed Package: optimizer (PECL)
PHP Version: 5.5.0alpha5 OS:
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: lisachenko dot it at gmail dot com
New email:
PHP Version: OS:

 

 [2013-03-05 06:50 UTC] lisachenko dot it at gmail dot com
Description:
------------
php-5.5.0alpha5-nts-Win32-VC11-x86

PHP 5.5.0alpha5 (cli) (built: Feb 21 2013 17:11:43)
Copyright (c) 1997-2013 The PHP Group
Zend Engine v2.5.0-dev, Copyright (c) 1998-2013 Zend Technologies
    with Zend Optimizer+ v7.0.0, Copyright (c) 1999-2013, by Zend Technologies

There is a strange issue with Optimizer+ when some loaded classes can "disappear". It's related to the dynamic includes and filter system. 
Go! AOP library uses this technique to perform "monkey-patching" before PHP parser.

Test script:
---------------
https://gist.github.com/lisachenko/00fa92f811511f347e3a

// bug.php
<?php
class BugLoader extends php_user_filter
{

    public function filter($in, $out, &$consumed, $closing)
    {
        eval("class Test extends ArrayObject {}");
        return PSFS_PASS_ON;
    }
}

function dynamicInclude()
{
    return "php://filter/read=bug.test/resource=test.php";
}
echo "ArrayObject class ", class_exists('ArrayObject') ? 'exists' : 'not found';
stream_filter_register('bug.test', 'BugLoader');
include dynamicInclude();

//test.php
<?php
// Empty file here

Expected result:
----------------
ArrayObject class exists

Actual result:
--------------
ArrayObject class exists
Fatal error: Class 'ArrayObject' not found in ~/bug.php(7) : eval()'d code on line 1

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2013-03-05 11:00 UTC] dmitry@php.net
-Status: Open +Status: Closed -Assigned To: +Assigned To: dmitry
 [2013-03-05 11:00 UTC] dmitry@php.net
Fixed in GitHub repository.
 [2013-03-15 20:47 UTC] dmitry@php.net
Automatic comment on behalf of dmitry@zend.com
Revision: http://git.php.net/?p=php-src.git;a=commit;h=fae0a738df8542d909c4e56b4af89abcfbc2f99e
Log: Fixed bug #64353 (Built-in classes can be unavailable with dynamic includes and Optimizer+)
 [2013-11-17 09:31 UTC] laruence@php.net
Automatic comment on behalf of dmitry@zend.com
Revision: http://git.php.net/?p=php-src.git;a=commit;h=fae0a738df8542d909c4e56b4af89abcfbc2f99e
Log: Fixed bug #64353 (Built-in classes can be unavailable with dynamic includes and Optimizer+)
 
PHP Copyright © 2001-2020 The PHP Group
All rights reserved.
Last updated: Sat Apr 04 00:01:24 2020 UTC