"No, the problem results because lowercase i (in most languages) and uppercase I (in most languages) are not actually considered to be the upper/lower variant of the same letter in Turkish. In Turkish, the undotted ı is the lowercase of I, and the dotted İ is the uppercase of i. If you have a class named Image, it will break if the locale is changed to turkish because class_exists() function uses zend_str_tolower(), and changes the case on all classes, because they are supposed to be case insensitive. Someone else above explained it very well:
"class_exists() function uses zend_str_tolower(). zend_str_tolower() uses zend_tolower(). zend_tolower() uses _tolower_l() on Windows and tolower() on other oses. _tolower_l() is not locale aware. tolower() is LC_CTYPE aware."
Edit: Someone else later said the following (I'm wondering if it's true):
"This, practically, can't be fixed. Mainly because there's no way to know if 'I' is uppercase of 'i' or 'ı' since there's not a separate place for Turkish 'I' in code tables. The same holds for 'i' (can't be known if it's lowercase of 'I' or 'İ'). I told 2 years ago and will say it again: PHP should provide a way to turn off case-insensitive function/class name lookup. No good programmer uses this Basic language feature since identifiers are case-sensitive in all real languages like Python, Ruby, C#, Java."
Maybe it breaks if you embed unicode strings or something. What do other languages do?
Based on the behavior of this bug, it appears that the way PHP handles this case insensitivity is that it just lowercases all class and function names before resolving them. And this bug in particular shows up for Turkish because 'i' is not the lowercase equivalent of 'I'.
Pretty much all other modern languages are case sensitive, so I'd be surprised to find this issue elsewhere.
Obviously, case-insensitive identifiers are a bad idea, but PHP is stuck with them at this point.
Or anywhere for that matter?
There is no "they" in this equation. There is no person who should be held more accountable than you or I for fixing this problem.
The choices are simple:
1) Fix the problem
2) Find a work around
3) Don't use PHP
What's that? There is a lot of open source software that you wanted to use for free that's written in PHP that does just what you need except for this tiny little trivial thing that should be easy to fix? Well too bad!
Trade off the cost of fixing it against the cost of rewriting the big, free, open source package that's written in PHP you wanted to use, in the programming language of your choice, and stop complaining.
Not wanting to fix a bug because it's not worth the time or risks breaking backward compatibility is perfectly fine by me. But at least take a decision and say something.
If they don't plan on fixing it they should say something like "We believe this is a minor bug that only concerns a small number of users. In order to fix this we'd need to change X, Y and Z and make sure we don't introduce regressions. If you want to try and do it we'll be glad to review your patches. In the meantime you can use this workaround: [...]".
I hate it when I submit a bug report and it's being ignored. You also build a strawman argument with the "lot of open source software that you wanted to use for free". It's a bug and should be fixed (even if the fix is closing the ticket as "wontfix").
http://news.ycombinator.com/item?id=4188167
specifically the complaint that this problem manifests with lots of off-the-shelf software (although I suppose he didn't specify FOSS in his original comment).
However, I wasn't directly responding to that guy, I was more responding to what I feel has been aptly described as a "witch hunt" by others on this page.
It might not be an easy fix if you're not familiar with PHP's guts
10 years is a long time for someone to have the chance to get familiar with it.
Even if you assume that for 8 years, everyone was saying "oh, it will get fixed some time" even 2 years is a long time for anyone affected by this problem seriously enough to become familiar enough with PHP to fix the problem if that's the path that will produce the most value for them (ie. if there's enough value in some existing codebase or off the shelf software to warrant fixing this if there's truly no other workaround).
Still, I can see the sense in promoting major issues like this with PHP, but posting the bug report on the front page of HN is far less useful than, say, writing a blog post about it with some case studies of where the problem has been manifest, how people have dealt with it, the history of the bug, etc.
Actually that's a good blog post, might put it on my list ;)
We all know PHP has its shortcomings, but there appears to be a witch hunt going on here.
I think some of the witch hunt comes in attempt to steer people away from a language which is badly designed and has a million bugs which cannot be fixed without breaking most of the existing code written for the language.
Pestering a language like that is only fair.
While I'm sure it gets tiresome for those who for whatever reason have to work or prefer working in PHP, it is only a polite gesture to the software-developers who has yet to take that dark path.
If they can be dissuaded, they should.
It is important that people should be fully aware of the technical liability they are taking on when they adopt PHP for nontrivial projects.
It isn't reasonable to demand that other people fix the huge collection of weird bugs in your project. Particularly when they are not invested in PHP (any more). PHP's bug collection is a strong reason not to invest in PHP (any more). If it is important to you to encourage PHP adoption, then YOU fix the bugs.
I am not wasting my life working around this nonsense because there is no reason why I should have to. There are alternatives which already work correctly.
Don't trade off against the cost of rewriting.
Trade off against the cost of using any of the well-developed alternatives which do not have the same bugs, the same volume of bugs, or the same internal processes which generate and shelter bugs for years on end.
PHP is crap. Not even classical ASP had such bugs and it was perfectly passing the Turkey test (http://www.codinghorror.com/blog/2008/03/whats-wrong-with-tu...) and Unicode supporting languages didn't have such a bug. E.g. Java, Python.
PHP is crap. This bug is clearly a WONTFIX, it's been 10 years since it is reported. I remember this bug when I was 14, thank God I moved on to other languages afterwards.
edit: not trolling, just curious. What drives people to complain about specific, well-defined open source bugs without any effort to fix it? I understand hard-to-nail down issues like user experience, but this shouldn't be that hard to plan out and fix independently.
If there are viable alternative projects which are more responsive to bug reports, that is more promising for the future - if a second bug I see is reasonably likely to be fixed in the future, I can feel more confident basing my own code on it.
People spend months and years writing apps on top of things like PHP and once they have the code they don't necessarily have a lot of choice. At that point maybe you fix the bugs in your dependencies rather than rewrite your own app. But when you have a choice, you don't adopt a tool which is going to leave you with this much technical liability.
This is offered peacefully in an attempt to explain the question which seems to confuse you.
But come on. This language is complete crap. Code spontaneously fails depending on the locale? And the bug has been open for ten years and still is not fixed? And this is only one bizarre and inexplicable bug out of hundreds, maybe thousands, of bizarre and inexplicable bugs in PHP.
This language isn't defensible. If you want to say that it's worth dealing with the flaws due to the ecosystem, fine, fair enough. But don't tell us that PHP is no worse than any other language. It's far worse.
While I tend to agree that I would not use PHP for new projects, I would disagree that it's indefensible. All you need to defend it is, "it's easy." In the sense of, "it's nearby, it's within reach." If it happens to be the language installed on your system, its use is automatically defensible on those grounds alone.
It might not nurture you and love you and cherish you; hell, it may abuse you at times, as any language with idiosyncrasies does. It might even have more idiosyncrasies than other languages do. But those do not make a relationship indefensible -- merely difficult. And in some cases, the difficulty makes the love even more binding -- which is why we still have people who program in low-level languages, for example, even though those have all the more tendency to abuse you for the tiniest mistake you make.
It doesn't spontaneously fail. The languages functions are case-insensitive and they documented this. [1] [2] When you change the locale to Turkish the letters change. Thus, the class name changes and no longer works as expected.
So it is documented because it may not as expected, but it is not spontaneous.
I'd accept that you cannot reference class "info" using name "Info" in Turkish locale, but that's not the case here.
Case sensitivity changing depending on locale would be weird, but at least vaguely sensible. Identical strings no longer matching is just plain wrong.
Yes, the PHP ecosystem is friendly, easy, cheap, etc. etc.
But as a programming language per se... Come on, PHP.
It is wildly successful despite this and many other bugs.
I only wish that the people who spend as much time attacking PHP and it's developers endlessly would instead focus some of that energy into helping to improve PHP, but I guess some of us are just negatively charged.
Sad that we have yet another anti-PHP posting hitting the front of HN in as many days, let the hating re-commence (again)...
Your suggestion that people improve PHP instead of attacking it is naive. PHP is, as you said, a big legacy open source project. As a result of that, it's basically impossible to make the extreme, breaking changes that many people (me included) think would be required to make it a reasonable competitor to the existing options. (And the PHP community is not especially inclined to change. It took years for short array syntax to get added to the language. If something as obviously beneficial as that is going to be hotly debated, making real, breaking changes is impossible.)
Faced with the alternatives of trying to radically change PHP (which is, as I said above, impossible) or to use and improve other languages and frameworks, I think the choice is obvious. It was one thing 5-10 years ago when there weren't necessarily good or mature alternatives, but we have many choices now. In my opinion, it makes very little sense to use something with as much extraordinarly painful legacy baggage as PHP unless you have an exceptionally good reason for doing so.
* Note that I am not including myself in this list. But any trivial search for "what's wrong with PHP", much less "PHP sucks" produces 5+ years of very bright, articulate, sometimes downright famous programmers making this same point about PHP. Most recently Jamie Zawinski at http://www.jwz.org/blog/2011/05/computational-feces/#comment...
And if you are going to design a new language (that's what "improved PHP" would be), you have very little to gain in basing your work on PHP. The ecosystem is in the current PHP, and it is as likely to transition to completely different language as it would be to transition to your "improved PHP".
As someone who would rather not ever work with PHP again, the best thing is to simply focus on other languages and environments, helping to bolster those ecosystems.
http://www.codinghorror.com/blog/2008/03/whats-wrong-with-tu...
Other languages like PHP (partially), BASIC or Pascal are case insensitive, so lookup has to be done case-insensitively which means that case has to be normalized, so transforming case of identifier becomes necessary. If it can't be done consistently, that's a problem.
The programmer can be sloppy/lazy and still have thing turn out largely as expected. If you're just learning how to program, this makes it a bit easier, since a whole class of possible problems goes away.
The only way to make it not work is to first change the case in one locale and then case-insensitive compare it in another locale. Why would this kind of operation ever happen? Any sane situation should "just work":
- in declaration convert to lower-case and save, in usage convert to lower-case and lookup -> has to work
- in declaration save original, in usage search all classes with case-insensitive compare -> has to work
How was that bug ever created in the first place? I get the fact that "I" doesn't match to lower-case "i" in tr_TR, but why does it matter when comparing strings which should be equal? Just be consistent in how both the declarations and usages are converted...
Granted given the usual pragmatism of PHP someone should have just hacked something in by now.
Just as an example, text-transform: uppercase has been broken in Turkish for all major browsers until I believe Firefox finally fixed it late last year, after having a bug open for nearly a decade.
Of course that might be bit late to do now, there is probably too much text encoded in the current format.
I blame Atatürk. If I had a time machine, I'd skip killing Hitler and travel back to the language reform time. "Do you know how much trouble this is going to cause us? Reuse the X, make one a dotted e. I don't care, this is going to fuck everything up!"
PHP is cool, it is useful, it is a magnet for bad developers. This way they don't pollute our ecosystems.