-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Undefined array index for locale tr causing error #5305
Comments
FYI, using the method, linked in the description, actually works for us. We created a patch for our specific use case, which added the method like so: private function array_change_key_case_unicode($arr, $c = CASE_LOWER) {
$c = ($c == CASE_LOWER) ? MB_CASE_LOWER : MB_CASE_UPPER;
foreach ($arr as $k => $v) {
$ret[mb_convert_case($k, $c, "UTF-8")] = $v;
}
return $ret;
} Of course, all calls to |
Is it the expected behavior of the
The conversion should be done on a per-character basis regardless of the character's position. How does one reproduce this issue in a development environment? Which operating system is it reproducible on? Apart from having the locale available in the system, how does one set it for the PHP application? Which of the
|
To me, it is the expected behaviour, due to the documentation you mentioned. However, accessing an array index should not cause any errors, unless there is an explicit check for the key followed by a if(!array_key_exists($key, $array)) {
throw new FooException("Missing required key '$key'");
} In this case an exception is just fine, otherwise not - at least to me.
I also think that there shouldn't be a conversion at all. Personally, I'd rather have an enum to avoid having different values in the first place. But that's probably some kind of backwards compatibility. Not sure, though, as I'm not too savvy of this repo.
We are working on a project using Pimcore with Docker on a Mac. Which means that this can be used to reproduce the issue locally, provided that the I'm aware that this is probably not what you had in mind when asking for reproducible steps. So, this was just for full disclosure. I've had a look at Pimcore's code (which builds on top of Symfony). So, ultimately, the locale is set, using
Here's what your command outputs for us: # tr_CY ISO-8859-9
# tr_CY.UTF-8 UTF-8
# tr_TR ISO-8859-9
# tr_TR.UTF-8 UTF-8 Using LC_CTYPE=tr_TR.utf8;LC_NUMERIC=C;LC_TIME=tr_TR.utf8;LC_COLLATE=tr_TR.utf8;LC_MONETARY=tr_TR.utf8;LC_MESSAGES=tr_TR.utf8;LC_PAPER=tr_TR.utf8;LC_NAME=tr_TR.utf8;LC_ADDRESS=tr_TR.utf8;LC_TELEPHONE=tr_TR.utf8;LC_MEASUREMENT=tr_TR.utf8;LC_IDENTIFICATION=tr_TR.utf8 |
You're right. It exists due to the issues like #5226 where the results returned by the query may have been processed by the portability middleware and needs to be adjusted back to a predictable case. If we find a way not to use the middleware within the schema managers, this conversion will be no longer necessary.
What exactly in the documentation suggests that the case conversion behavior depends on the position of the character?
You're right. Right now, I don't have the environment to reproduce this issue. At least, its subset like: $row = array_change_key_case(['Index_Type' => 1], CASE_LOWER);
// expected: ['Index_type' => 1] If you provide the instructions on building such an environment in Docker and reproducing the above behavior, it may help address this issue sooner than later. |
According to https://forge.typo3.org/issues/76804#note-8,
So that's probably the problem, not the position of the character in the string. |
The issue can be reproduced on Linux as follows:
|
Current behaviour
When using the locale
tr
, thearray_change_key_case
function calls do not properly lower case the array indexes. For example,Index_Type
will be converted toIndex_type
.Here are the related files that cause the error for us (in order of exectuion):
dbal/src/Schema/AbstractSchemaManager.php
Lines 222 to 229 in baf6efe
dbal/src/Platforms/AbstractMySQLPlatform.php
Lines 153 to 164 in baf6efe
dbal/src/Schema/MySQLSchemaManager.php
Lines 80 to 105 in baf6efe
Expected behaviour
Either lowercasing should be done using
mb_*
methods or do not use different values for index and column aliases, where the latter would probably be a BC.Steps to reproduce
tr
locale.MySqlSchemaManager
and calllistTableIndexes
The text was updated successfully, but these errors were encountered: