Mantis - Quercus
|
|||||
Viewing Issue Advanced Details | |||||
|
|||||
ID: | Category: | Severity: | Reproducibility: | Date Submitted: | Last Update: |
4522 | major | always | 04-27-11 11:52 | 04-27-11 11:52 | |
|
|||||
Reporter: | tokeefe | Platform: | |||
Assigned To: | OS: | ||||
Priority: | normal | OS Version: | |||
Status: | new | Product Version: | 4.0.11 | ||
Product Build: | Resolution: | open | |||
Projection: | none | ||||
ETA: | none | Fixed in Version: | |||
|
|||||
Summary: | 0004522: Case sensitive autoload | ||||
Description: |
The Quercus implementation of "class_exists()" appears to lowercase the incoming string, then pass this string to __autoload() and cache the result of __autoload. If a custom __autoload() function uses this incoming string to load a PHP file from disk -- where case can matter -- the cached __autoload result can cause issues. All subsequent attempts to call class_exists(), depending on that function to autoload the file will fail even if one later uses the correct case. To test the issue, create a file (a class) Foo/Bar/Biz.php Then create an __autoload method similar to the following e.g., 31 function __autoload($name=null) 33 { 34 $class = explode("\\", $name); 35 $class = implode("/", $class); 36 37 $path = dirname(__FILE__) . "/../.."; 38 $fullfile = "$path/$class.php"; 39 40 if(!file_exists($fullfile)) 41 throw new ClassException(ClassException::CLASS_NOT_FOUND, $name); 42 43 include_once($fullfile); 44 } Then call class_exists() with both incorrect and correct case (in that order): class_exists("Foo\Bar\biz"); class_exists("Foo\Bar\Biz"); Since the first invocation of class_exists() fails and the result is cached, the subsequent invocation will also fail until you reboot the webserver. This issue is especially evident when using a tokenized URL (input by the client) to load Controllers/Views a la Zend Framework. Temporary workaround: Do not let class_exists() attempt the __autoload by passing false as the second argument. Simply call autoload manually e.g., 117 if(! class_exists($name, false)) 118 __autoload($name); |
||||
Steps To Reproduce: | |||||
Additional Information: | |||||
Relationships | |||||
Attached Files: |
There are no notes attached to this issue. |