Edit report at https://bugs.php.net/bug.php?id=49625&edit=1
ID: 49625
Comment by: abr28 at cam dot ac dot uk
Reported by: jo at feuersee dot de
Summary: spl_autoload and case sensitivity
Status: Not a bug
Type: Bug
Package: SPL related
Operating System: Linux
PHP Version: 5.3.0
Block user comment: N
Private report: N
New Comment:
Like so many others I also think this is a much too obvious bug, unexpected
behaviour, etc ... you name it. It's a poor implementation that needs to be
fixed even if it means breaking compatibility with PHP code that relyies on it,
code + files which are poorly cased anyway (!).
However you can maintain compatibility by introducing a new function which
alters a case sensitivity flag. Just like you already have
spl_autoload_extensions() to hint/restrict the extensions for spl_autoload(),
you can have a function spl_autoload_case() and call it once, e.g.:
spl_autoload_case(false); // for the broken lowercase spl_autoload()
spl_autoload_case(true); // to respect case sensitivity
You'd call this before spl_autoload() gets called. You can even make the
default to be lowercase, like you so insist on having.
This way you don't break compatibility -- although you should(too many aspects
of PHP encourage bad coding already).
Previous Comments:
------------------------------------------------------------------------
[2013-03-19 12:49:14] james at jamestandy dot com
Also add my support to
FIX THIS BUG!!!
Just tried adding the Ebay Trading API to my existing site, which is using
spl_autoload.
Because the ebay team (like it seems every other sensible dev on the entire
planet) uses CamelCased filenames, I now have 3 choices:
1: Do not use spl_autoload (Not an option because this would break our
existing site).
2: Do not use the Ebay Trading API, or write my own implementation of this
from scratch. (Also not an option for obvious reasons).
3: Rename over 1000 files, and replace every CamelCase instance in each and
every file with lower case names.
3 is looking to be my only option, which of course would need repeating each
and every time Ebay update their API, so is really NOT a viable option.
------------------------------------------------------------------------
[2013-01-30 09:41:30] jurchiks101 at gmail dot com
Bumping this bug, at least add a boolean parameter to it for case-sensitivity.
This should be literally a 5-minute job for the devs, why has nobody fixed it
for
3 years and counting? Have you no shame?
------------------------------------------------------------------------
[2013-01-09 10:00:35] wim at asgc dot be
Since I have an extensive codebase relying on classes defined with uppercase
starting letter and I saw the 'tip' in the documentation (see below) , I wanted
to switch. To my surprise I bumped into this issue with spl_autoload_register
(needless to say that it works on a Windows box as a charm and breaks terribly
on a Linux box).
It definitely is a bug which should be mentioned clearly in the documentation.
In addition I would strongly suggest the __autoload function will not be
deprecated until this is fixed.
--
>From the documentation :
Tip
spl_autoload_register() provides a more flexible alternative for autoloading
classes. For this reason, using __autoload() is discouraged and may be
deprecated or removed in the future.
--
------------------------------------------------------------------------
[2012-12-17 16:01:57] admin at tandyukservers dot co dot uk
Status: Not a bug
Bullshit.
IS A BUG.
When will this be recognised as such by you php devs and added to the list of
bugs to be fixed!
------------------------------------------------------------------------
[2012-06-15 19:59:25] jdornan at stanford dot edu
This seems like a 20 min fix to me, and I've never looked the sql_autoload code
before. I spent a good deal of time spinning my wheels on this. I don't see why
anyone should lose time of this very obvious bug. However it's better to patch
that to bitch, as I always say. I'll submit my patch and see what happens. It's
not big deal if this is not fixed, since it's so easy to fix I can keep fixing
it with each release.
Here is a diff, I'll submit the patch with the "Add a Patch" link.
225d224
< char *lc_class_file;
227d225
< int lc_class_file_len;
229d226
< int mixed_case = 0;
235,236c232
< lc_class_file_len = spprintf(&lc_class_file, 0, "%s%s", lc_name,
file_extension);
< class_file_len = spprintf(&class_file, 0, "%s%s", class_name,
file_extension);
---
> class_file_len = spprintf(&class_file, 0, "%s%s", lc_name,
file_extension);
252,261c248
< mixed_case = 1;
< }
<
< /* fall back to lowercase file name. should issue deprecated warning.
*/
< if (ret != SUCCESS) {
< ret = php_stream_open_for_zend_ex(lc_class_file, &file_handle,
ENFORCE_SAFE_MODE|USE_PATH|STREAM_OPEN_FOR_INCLUDE TSRMLS_CC);
< }
<
< if (ret == SUCCESS) {
< if (!file_handle.opened_path && mixed_case == 1) {
---
> if (!file_handle.opened_path) {
263,264d249
< } else if(!file_handle.opened_path && mixed_case == 0) {
< file_handle.opened_path = estrndup(lc_class_file,
lc_class_file_len);
290d274
< efree(lc_class_file);
295d278
< efree(lc_class_file);
331d313
<
PS: I really hate this bug with a passion.
------------------------------------------------------------------------
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=49625
--
Edit this bug report at https://bugs.php.net/bug.php?id=49625&edit=1