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

From: Date: Thu, 23 Oct 2014 15:40:46 +0000
Subject: Bug #66773 [Com]: Autoload with Opcache allows importing conflicting class name to namespace
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-188277@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 Comment by: nikic@php.net Reported by: carl dot vuorinen at w3 dot fi Summary: Autoload with Opcache allows importing conflicting class name to namespace Status: Assigned Type: Bug Package: opcache Operating System: Linux (Ubuntu) PHP Version: 5.5.9 Assigned To: dmitry Block user comment: N Private report: N New Comment: I think all we need to do is drop the if (+ 10 lines) at http://lxr.php.net/xref/PHP_TRUNK/Zend/zend_compile.c#4723, which checks whether a class with the imported name already exists. Previous Comments: ------------------------------------------------------------------------ [2014-10-23 11:39:09] dmitry@php.net Nikta, it would be great if you can take care about this. I completely forgot namespaces implementation details. I'm even not sure, if it can be done without hacks. ------------------------------------------------------------------------ [2014-10-23 10:07:33] nikic@php.net I agree with Dmitry, it would be best to allow shadowing class definitions with imports in PHP 7. The current behavior is pretty weird, especially as it depends on the order in which classes are loaded. ------------------------------------------------------------------------ [2014-10-23 09:17:47] dmitry@php.net Unfortunately, the patch is wrong. Opcache compiles each script separately by design. Otherwise, it'll may make dependencies on other scripts. And later to unpredictable behavior, if some of those scripts are changed and recompiled but depended is not. The patch breaks this rule. Actually, the behavior with opcache seems better :) May be it makes sense switching to it in PHP7. ------------------------------------------------------------------------ [2014-10-22 09:41:14] jpauli@php.net I got a patch at https://github.com/jpauli/ZendOptimizerPlus/compare/66773 I compiles and works just fine for 5.5, shouldn't diff for other versions. Dmitry, this needs review ------------------------------------------------------------------------ [2014-06-23 16:17:26] devosc at gmail dot com I prefer the new behaviour and would like it to be kept/maintained. ------------------------------------------------------------------------ The remainder of the comments for this report are too long. To view the rest of the comments, please view the bug report online at https://bugs.php.net/bug.php?id=66773 -- Edit this bug report at https://bugs.php.net/bug.php?id=66773&edit=1

« previous php.bugs (#188277) next »