|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2014-02-25 21:29 UTC] 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 Patchesbug66773.diff (last revision 2016-01-13 10:06 UTC by dmitry at zend dot com)Pull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Fri Nov 07 08:00:02 2025 UTC |
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:7Same issue here. The test script could be reproduced: $ lsb_release -a LSB Version: core-2.0-amd64:core-2.0-noarch:core-3.0-amd64:core-3.0-noarch:core-3.1-amd64:core-3.1-noarch:core-3.2-amd64:core-3.2-noarch:core-4.0-amd64:core-4.0-noarch Distributor ID: Ubuntu Description: Ubuntu 14.04 LTS Release: 14.04 Codename: trusty $ php -v PHP 5.5.9-1ubuntu4 (cli) (built: Apr 9 2014 17:11:57) 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 $ php -i | grep opcache.enable_cli opcache.enable_cli => Off => Off $ php execute.php PHP Fatal error: Cannot use Other\Bar as Bar because the name is already in use in /tmp/a/some_foo.php on line 5 PHP Stack trace: PHP 1. {main}() /tmp/a/execute.php:0 PHP 2. spl_autoload_call() /tmp/a/execute.php:13 PHP 3. {closure:/tmp/a/execute.php:6-8}() /tmp/a/execute.php:0 PHP 4. spl_autoload() /tmp/a/execute.php:7 Fatal error: Cannot use Other\Bar as Bar because the name is already in use in /tmp/a/some_foo.php on line 5 Call Stack: 0.0002 235776 1. {main}() /tmp/a/execute.php:0 0.0005 242720 2. spl_autoload_call() /tmp/a/execute.php:13 0.0005 242752 3. {closure:/tmp/a/execute.php:6-8}() /tmp/a/execute.php:0 0.0005 242880 4. spl_autoload() /tmp/a/execute.php:7Hey, What is the status of this issue? This is still happening using the gist above and also happened on one of our php7 hosts on production. $ php -v PHP 7.0.4-6+deb.sury.org~trusty+5 (cli) ( NTS ) Copyright (c) 1997-2016 The PHP Group Zend Engine v3.0.0, Copyright (c) 1998-2016 Zend Technologies with Zend OPcache v7.0.6-dev, Copyright (c) 1999-2016, by Zend Technologies uname -a "Linux dev 3.13.0-79-generic #123-Ubuntu SMP Fri Feb 19 14:27:58 UTC 2016 x86_64 x86_64 x86_64 GNU/Linux" I have checked PHP's source code but haven't seen the patch there. Any idea how this can be resolved? ThanksHey, I have tried the attached patch: $ /usr/bin/php-backup -v PHP 7.0.4-6+deb.sury.org~trusty+5 (cli) ( NTS ) Copyright (c) 1997-2016 The PHP Group Zend Engine v3.0.0, Copyright (c) 1998-2016 Zend Technologies with Zend OPcache v7.0.6-dev, Copyright (c) 1999-2016, by Zend Technologies $ /usr/bin/php-backup execute.php PHP Fatal error: Cannot use Other\Bar as Bar because the name is already in use in /php7test/some_foo.php on line 5 Fatal error: Cannot use Other\Bar as Bar because the name is already in use in /php7test/some_foo.php on line 5 $ php -v PHP 7.1.0-dev (cli) (built: Mar 31 2016 09:45:43) ( NTS ) Copyright (c) 1997-2016 The PHP Group Zend Engine v3.1.0-dev, Copyright (c) 1998-2016 Zend Technologies $ php execute.php self: Some\Bar parent: Other\Bar $ It seems like it works with the gist example. Having said that, it's hard to say if all cases are covered, plus I did have segfault while compiling (and I have filed a bug) which I am not sure if it was related or not.