Ticket #1485470 (closed Patches: fixed)

Opened 3 months ago

Last modified 8 weeks ago

Setting locale to tr_TR breaks PHP

Reported by: hayalci Owned by: till
Priority: 5 Milestone: 0.2-stable
Component: PHP backend Version: 0.2-beta
Severity: normal Keywords:
Cc: gokdenizk@…

Description

Hi,

There is an odd problem with Turkish language and PHP. To cut it short, in Turkish there are "dotted capital I" and "dotless i" characters, and "i != I"

PHP calls strtolower() on function/class name before function calls. if the system locale is set to tr_TR, functions that contain "I" in their name cannot be found and called.

As roundcube sets locale to the selected language, using Turkish translation OR a browser which lists Turkish as preferred language is impossible currently. I get a white page and the following error in the logs.

The error I got.

PHP Fatal error:  Call to undefined method MDB2_Driver_Datatype_sqlite::getDBInstance() in ./roundcubemail/program/lib/MDB2/Driver/Datatype/Common.php on line 1117

The attached patch fixes the issue by setting locale to "en_US" if user requests "tr_TR". This solved the problem and it worked with the Turkish translation of the interface. No side effects to non-Turkish users.

For more info about this Turkish locale problem:

Attachments

fix_turkish_lang.patch (1.0 kB) - added by hayalci 3 months ago.
fix locale for Turkic languages
turkish_cosmetic_fix.patch (471 bytes) - added by hayalci 3 months ago.
Add localized name of Turkish languge

Change History

Changed 3 months ago by tensor

  • component changed from Core functionality to PHP backend

Can you test whether some of the more specific LC_XXX constants instead of LC_ALL fix the issue?

Changed 3 months ago by hayalci

  • cc gokdenizk@… added

Do you want me to try changing the only setlocale present in the file before the patch, or the setlocale in the TR specific case of the patch ?

Changed 3 months ago by tensor

Something like this:

setlocale(LC_ALL, $_SESSION['language'] . '.utf8');
if ($_SESSION['language'] == 'tr_TR'){
  // workaround for http://bugs.php.net/bug.php?id=18556
  setlocale(LC_XXX, 'en_US.utf8'); 
}

This will allow to change only XXX part of locale definition. Other parts will stay at their Turkish definitions. Try LC_CTYPE first.

Changed 3 months ago by tensor

And please use svn trunk to make the patch. There were some changes in this area.

Changed 3 months ago by alec

I think fix should go to autoload() in iniset.php. And also ku and az locales are affected.

Changed 3 months ago by hayalci

fix locale for Turkic languages

Changed 3 months ago by hayalci

Add localized name of Turkish languge

Changed 3 months ago by hayalci

Updated the fixes to include all affected locales, and apply against svn trunk.

Changing only LC_CTYPE works. I'm not so sure about integrating it to _ _autoload(), this should be done where the locale is set.

Note this this fix makes it impossible to make case insensitive searches using 'I', but before the patch you couldn't do it anyway :D Solution would be to check for these locales before a search and set CTYPE, then revert it after CTYPE. Maybe I'll implement it.

Changed 2 months ago by hayalci

Hi, can these small patches and updated Turkish translation be commited to trunk ? (The translation file was sent to the list at the same time with this bug, I can resend it if it was lost)

Changed 2 months ago by alec

  • owner set to till

Translation updated in r2039. I'm still not sure what to do with this ticket's main issue. Assigning to till.

Changed 2 months ago by hayalci

Hi, thanks for commiting translations.

As for the locale issue, In case the patch is not applied, it is impossible to use roundcube either

a translated interface.

As roundcube tries to determine language from browser settings, it sets the language to TR if browser says so, after that you only get a white empty screen from roundcube, and after that it is only possible to use roundcube with an English interface by poking the database.

The only drawback is searches involving 'dotless small i' and 'I' will be case sensitive. Also, as I am not too experienced in roundcube code, if you can point me to places in code where searches are performed, I can try to write and test a patch that changes locale before and after searches to enable case insensitive search. But after all that is a minor problem.

I am not very sure if this bug happens with az and ku locales, but the php bug says so.

Changed 8 weeks ago by alec

  • status changed from new to closed
  • resolution set to fixed

Fixed in r2060.

Note: See TracTickets for help on using tickets.