Bug #66773 [Opn]: Autoload with Opcache allows importing conflicting class name to namespace

From: Date: Tue, 11 Mar 2014 12:26:00 +0000
Subject: Bug #66773 [Opn]: Autoload with Opcache allows importing conflicting class name to namespace
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-184716@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=66773&edit=1 ID: 66773 User updated by: carl dot vuorinen at w3 dot fi Reported by: carl dot vuorinen at w3 dot fi Summary: Autoload with Opcache allows importing conflicting class name to namespace Status: Open Type: Bug Package: opcache Operating System: Linux (Ubuntu) PHP Version: 5.5.9 Block user comment: N Private report: N New Comment: Here is a more detailed output with both OPcache enabled and OPcache disabled. Same behaviour also reproduced in few other environments. $ php -v PHP 5.5.9-1+sury.org~saucy+1 (cli) (built: Feb 13 2014 15:58:58) Copyright (c) 1997-2014 The PHP Group Zend Engine v2.5.0, Copyright (c) 1998-2014 Zend Technologies with Zend OPcache v7.0.3, Copyright (c) 1999-2014, by Zend Technologies with Xdebug v2.2.3, Copyright (c) 2002-2013, by Derick Rethans $ php -i | grep opcache.enable_cli opcache.enable_cli => On => On $ php execute.php self: Some\Bar parent: Other\Bar $ sudo nano /etc/php5/cli/php.ini $ php -i | grep opcache.enable_cli opcache.enable_cli => Off => Off $ php execute.php Fatal error: Cannot use Other\Bar as Bar because the name is already in use in /tmp/path/some_foo.php on line 5 Call Stack: 0.0005 234520 1. {main}() /tmp/path/execute.php:0 0.0036 241464 2. spl_autoload_call() /tmp/path/execute.php:13 0.0036 241496 3. {closure:/tmp/path/execute.php:6-8}() /tmp/path/execute.php:0 0.0036 241624 4. spl_autoload() /tmp/path/execute.php:7 Previous Comments: ------------------------------------------------------------------------ [2014-02-25 21:29:48] carl dot vuorinen at w3 dot fi Description: ------------ Autoloading with Opcache enabled allows importing a class from another namespace with a name that is already in use in the current namespace and the code to execute successfully. Without Opcache the same code gives Fatal error. Test script: --------------- Here is a small sample script with a few files that will be autoloaded by the execute.php script. Some test results can be found in the comments. https://gist.github.com/cvuorinen/e7a19101d40c9fa0a959 Expected result: ---------------- Fatal error: Cannot use Other\Bar as Bar because the name is already in use in /tmp/path/some_foo.php on line 5 Actual result: -------------- self: Some\Bar parent: Other\Bar ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=66773&edit=1

« previous php.bugs (#184716) next »