ID: 49625 Updated by: sjo...@php.net Reported By: jo at feuersee dot de -Status: Open +Status: Bogus Bug Type: SPL related Operating System: Linux PHP Version: 5.3.0 New Comment:
Thank you for your bug report. Wontfix means: we agree that there is a bug, but there are reasons not to fix it. The reason here is that is spl_autoload becomes case sensitive, it will break scripts which depend on spl_autoload being case insensitive. Previous Comments: ------------------------------------------------------------------------ [2009-09-22 16:01:15] jo at feuersee dot de Description: ------------ This is basically the same as PHP bug #48129. Yes, I have read it "won't fix" My opinion on this is "won't fix" is not an option because it _is_ a bug and not fixing bugs does not work: 1) It is common practice in OO languages (including PHP) to give classes case sensitive names. Even the classes of PHP itself are case sensitive and usually start with capital letters (eg. DateTime, Exception, ...). PHP related projects like PEAR, Zend Framework etc. do the same. 2) In order to get a proper 1:1 mapping from class name to the file containing the PHP class definition, projects like PEAR or Zend Framework use the case sensitive class name, eg. System.php contains the class System. Again, this is common practice in other OO languages like C++. 3) What happens when the file system is case sensitive? See example: the script fails because the PEAR class System will be looked for in a file named system.php which does not exist because it is called System.php The workaround is using SPL_autoload_suxx instead. But look at the code: there are several compatibility issues (include_path separator : vs. ;), it does work but is not at all convenient. 4) What would happen if spl_autoload() wouldn't lowercase the class name when looking for a class definition? a) Filesystem is case sensitive It would work! The spl_autoload() would look for a file called System.php which exists, thus will be require'd b) Filesystem is not case sensitive It would still work! The spl_autoload() would look for a file called System.php Because the file system is case insensitive, it would use either System.php or system.php (or sYSTEM.PHP - you got the point?). Because on case insentive filesystems both files "System.php" and "system.php" are not allowed in the same directory, there is _no_ issue with backward compatibility. The only circumstances where it would break backwards compatibility would be on filesystem which is case insensitive but does not allow capital letters. Any real live examples of such a file system? Conclusion: The current specification of spl_autoload() with implicit lowercasing is excactly wrong. There has been, is and never will be any gain in this 'feature' since the class name itself inside PHP is case sensitive. Reproduce code: --------------- <?php /** * Demonstration of the current incompatibility * Make sure you have PEAR inside your PHP include_path */ // this should work but doesn't spl_autoload_register('spl_autoload'); // this does work //spl_autoload_register('SPL_autoload_suxx'); /** * Does the same as spl_autoload, but without lowercasing */ function SPL_autoload_suxx($name) { $rc = FALSE; $exts = explode(',', spl_autoload_extensions()); $sep = (substr(PHP_OS, 0, 3) == 'Win') ? ';' : ':'; $paths = explode($sep, ini_get('include_path')); foreach($paths as $path) { foreach($exts as $ext) { $file = $path . DIRECTORY_SEPARATOR . $name . $ext; if(is_readable($file)) { require_once $file; $rc = $file; break; } } } return $rc; } $binaries = array( 'mysql' => System::which('mysql'), 'mysqlbinlog' => System::which('mysqlbinlog'), 'php' => System::which('php') ); print_r($binaries); ?> Expected result: ---------------- Array ( [mysql] => /usr/bin/mysql [mysqlbinlog] => /usr/bin/mysqlbinlog [php] => /usr/local/bin/php ) Actual result: -------------- PHP Fatal error: Class 'System' not found in /srv/www/vhosts/www.easy-sew.de/ftpjung/bin/autoload.php on line 38 ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=49625&edit=1