mirror of
https://github.com/doctrine/orm.git
synced 2026-03-23 22:42:18 +01:00
DQL does not work when setlocale(LC_ALL, 'tr_TR'); was called before #4948
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @AnnaDamm on GitHub (Dec 18, 2015).
When you set the locale with
setlocalefor specific languages before using DQL, the Lexer splits the tokens wrong:(inside a ProductGroupMemberRepository EntityRepository class)
It breaks with the error message:
Error: Expected end of string, got 'I'After some debugging, I found that preg_split apparently works differently on tr_TR. it splits on different characters:
If I use
setlocalewithLC_NUMERICor comment the line out, or use other languages, everything works fine. Even though the regex and DQL are exactly the same thing.@Ocramius commented on GitHub (Dec 18, 2015):
Any pointers as to where the execution path in doctrine/lexer changes (when the locale is changed)?
@billschaller commented on GitHub (Dec 18, 2015):
I just wrote a test (#5565) for the lexer with a bunch of locales and it seems to be fine on Windows with PHP 5.6.13.
@Arany What OS and PHP version are you using?
@AnnaDamm commented on GitHub (Dec 18, 2015):
It is the same exexution path. The Problem appelarently lies in preg_split that takes the same regex and input. The only difference being the setlocale..
I tested it on different machines and now it looks to me like a php-bug. On the machine with 5.5.18 it breaks. On 5.5.30 everything is fine. Only that i do not have Access to the php Installation on the Server so i cannot Upgrade it..
@AnnaDamm commented on GitHub (Dec 18, 2015):
The Server is using CentOS.
@billschaller commented on GitHub (Dec 18, 2015):
@Arany I really don't think there's anything we can do in Doctrine core to mitigate this php bug. If the preg_* functions are behaving badly in the lexer, they're probably behaving badly elsewhere, which could lead to serious issues elsewhere in your app. There were some nasty locale thread safety bugs fixed in 5.5.21.
Your best bet is to get the administrator of the machine to update the PHP installation.
@halk commented on GitHub (Feb 13, 2016):
I just had the same error with PHP 5.6.18. Must be related to the host, as all is fine on my mac. The server runs Ubuntu.