Summary | $conf['sql']['charset'] is ignored |
Queue | Horde Base |
Queue Version | 3.3.5 |
Type | Bug |
State | Not A Bug |
Priority | 1. Low |
Owners | |
Requester | e.cerny (at) seznam (dot) cz |
Created | 12/15/2009 (5679 days ago) |
Due | |
Updated | 02/07/2010 (5625 days ago) |
Assigned | |
Resolved | 12/15/2009 (5679 days ago) |
Github Issue Link | |
Github Pull Request | |
Milestone | |
Patch | No |
wrong now because it relays on PEAR functionality that isn't there
anymore.
Understand ?
And this make this problem a Horde BUG!
I think Horde is doing the work just fine. You can check it by
manually echoing the result of, for example, convertToDriver method
from kronolith/lib/Driver/sql.php. You'll see that the text is
converted just fine.
What seems to be happening wrong is, for some reason I don't know,
mysql connection always defaults it's charset to 'latin1' (even if the
charset is set to utf8 in my.cnf in charset_set_server and
default_charset_set) and then the text with "special" characters,
which was converted fine at the php layer, is wrongly recorded into
the database as 'latin1', and thus the problem of unusable data saved.
I managed to solve this issue by adding:
[mysqld]
init_connect="SET NAMES 'utf8'"
and restarting mysqld. Now the text is just the same on horde and on
the db, which makes it good to be used from other tools (import/export
etc.).
Also, the mysql_set_charset function only works for PHP 5 >= 5.2.3. So
the workaround of editing PEAR's DB may no apply to all installs.
See if the init_connect option in my.cnf works for you. Hope it helps.
2. The conversion is done to the charset that you configured in your
database settings. If this doesn't match the charset that your
database is actually using, that's your fault.
unchangeable(so far) charset...
The PEAR code we tallk about has changed and you didn't do the
apropriet change of your code.
PEAR does not set character set on mysql connect anymore (because php
does not set character set on mysql database connect) so must you...
It's not about what character set my database is using because it's
about what character set is using the client side. The mysql module in
php which is default latin1 (UNCHANGEABLE DEFAULT).
It's on application to change it.
I'm telling you that the code that did this right before is doing it
wrong now because it relays on PEAR functionality that isn't there
anymore.
Understand ?
And this make this problem a Horde BUG!
2. The conversion is done to the charset that you configured in your
database settings. If this doesn't match the charset that your
database is actually using, that's your fault.
The data in database are stored as 8bit representation of multi-byte encoding.
If there was any conversion from mysql default encoding (latin1,
which is not able to hold multi-byte characters) to some other
encoding. It would not obviously work for multi-byte characters.
Horde simply stores utf-8 (if sql-charset is utf8) byte stream in
mysql as latin1
and the same way retrieves it back.
This bug in combination with php inability to change
default-character-set for mysql. May be considered not beeing a bug,
but it is one.
And when php becomes able to set mysql default charset Horde brokes.
utf8. So instead of "ěčřýáíéřč" there is
"žÅÄÅ¡ÄÅ¡ÄÅžýáÃ"
1. if any other application uses this it is imposible to convert
"žÅÄÅ¡ÄÅ¡ÄÅžýáÃ" to "ěčřýáíéřč"
because there are ilegal latin1 characters.
2. backup, restoring and moving database is made problematic
I solved this with
if ($dsn['charset']) {
if (!@mysql_set_charset($dsn['charset'])) {
return $this->mysqlRaiseError();
}
}
added to pear/DB/mysql.php connect function after database conect
Which made PEAR function the old way
But this in not a permanent solution. The next "pear upgrade DB" will
broke it again...
Priority ⇒ 1. Low
State ⇒ Not A Bug
Priority ⇒ 3. High
Type ⇒ Bug
Summary ⇒ $conf['sql']['charset'] is ignored
Queue ⇒ Horde Base
Milestone ⇒
Patch ⇒ No
State ⇒ Unconfirmed
Database charset defaults to latin1 whatever is set in
$conf['sql']['charset'].