[TYPO3-core] RFC #15790: Bug: CLI dispatcher uses the locale from the shell

Oliver Klee typo3-german-02 at oliverklee.de
Fri Sep 24 17:30:21 CEST 2010


This is an SVN patch request.

Type: Bugfix

Bugtracker references:
http://bugs.typo3.org/view.php?id=15790

Branches:
TYPO3_4-2, TYPO3_4-3, TYPO3_4-4 & trunk

Problem:
The PHP locale (particularly, LC_NUMERIC (which is part of LC_ALL)) has
an effect on how numbers are parsed. For example, the following code

$foo = floatval('3.14159');

will result in 3.14159 for the "C" locale (or an English locale) and in
3 for any Germany locale. This will lead to data corruption.

When running TYPO3 via Apache (ie., using the FE or normal BE), this is
no problem as PHP by default does not have a particular locale set.
However, when running TYPO3 via the CLI mode, the locale used in the
shell is used - and that often is something like "de_DE.utf8".

Solution:
We need to reset the locale in the CLI dispatcher to make sure numbers
are parsed correctly (and to have a clean slate).


How to test:

1. install attached test extension
2. set your locale on the shell, e.g. like this:
   export LC_NUMERIC="de_DE.UTF-8"
   (On Windows, you'll need to set the locale to "german" AFAIK)
3. execute the test script:
   typo3/cli_dispatch.phpsh localeTest
4. See that the "3.14159" is parsed as 3*
5. apply the patch
6. repeat step 3
7. see that the 3.14159 string now correctly is parsed as 3.14159


Notes:
We need +1 by testing from Linux, Mac and Windows.

* The original problem occurs only on one of my two test systems. I have
no idea why on the second system setting the locale on the shell has no
effect whatsoever on the PHP locale.


Oli
-------------- next part --------------
A non-text attachment was scrubbed...
Name: locales.diff
Type: text/x-diff
Size: 574 bytes
Desc: not available
URL: <http://lists.typo3.org/pipermail/typo3-team-core/attachments/20100924/4bc0206c/attachment.diff>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: T3X_cli_test-0_0_0-z-201009241724.t3x
Type: application/octet-stream
Size: 1146 bytes
Desc: not available
URL: <http://lists.typo3.org/pipermail/typo3-team-core/attachments/20100924/4bc0206c/attachment.obj>


More information about the TYPO3-team-core mailing list