[Tickets #10245] Re: Identities values disappear after an upgrade from H3
bugs at horde.org
bugs at horde.org
Thu Jun 30 13:28:33 UTC 2011
DO NOT REPLY TO THIS MESSAGE. THIS EMAIL ADDRESS IS NOT MONITORED.
Ticket URL: http://bugs.horde.org/ticket/10245
------------------------------------------------------------------------------
Ticket | 10245
Updated By | laurent.foucher at iut-tlse3.fr
Summary | Identities values disappear after an upgrade from H3
Queue | IMP
Version | Git master
Type | Bug
State | Feedback
Priority | 2. Medium
Milestone |
Patch |
Owners |
------------------------------------------------------------------------------
laurent.foucher at iut-tlse3.fr (2011-06-30 13:28) wrote:
In fact, i have a problem with encoding. Before migration, as
recommended, i'm converting the database from latin1 to utf8 like this :
iconv -f LATIN1 -t UTF-8 horde3.sql > horde3_UTF8.sql
sed -e 's/CHARSET=latin1/CHARSET=utf8/g' -i horde3_UTF8.sql
mysql --user=root -p --execute="DROP DATABASE horde; CREATE DATABASE
horde CHARACTER SET utf8 COLLATE utf8_general_ci;"
mysql --user=root --max_allowed_packet=16M -p
--default-character-set=utf8 horde < horde3_UTF8.sql
horde-db-migrate ....
I put some hooks in
/usr/share/php/Horde/Core/Prefs/Storage/Upgrade.php for debugging. The
systemlogintask is running and i get this error :
HORDE [imp] PHP ERROR: unserialize() [<a
href='function.unserialize'>function.unserialize</a>]: Error at offset
49 of 935 bytes [pid 17296 on line 64 of
"/usr/share/php/Horde/Core/Prefs/Storage/Upgrade.php"]
corresponding to the code :
if (($data = unserialize($data)) !== false) { .....
Apply this code (not all shown) :
mysql_query("SET NAMES 'utf8'");
$query = "SELECT pref_uid, pref_value FROM horde_prefs WHERE
pref_scope LIKE 'horde' AND `pref_name` LIKE 'identities'";
while ($row = mysql_fetch_array($result)) {
echo $row['pref_value'];
echo "\n--------------\n";
$unserialized = preg_replace('!s:(\d+):"(.*?)";!se',
"'s:'.strlen('$2').':\"$2\";'", $row['pref_value'] );
$data = unserialize($unserialized);
$pref_uid = $row['pref_uid'];
$new_data=array();
foreach ($data as $key => $val)
{
foreach ($data[$key] as $id => $value) {
$new_data[$key][$id] = $value ;
}
}
$new_data_serial = serialize($new_data);
$query = sprintf("UPDATE horde_prefs SET
`horde_prefs`.`pref_value` = '%s' WHERE `horde_prefs`.`pref_uid` LIKE
'$pref_uid' AND `horde_prefs`.`pref_scope` LIKE 'horde' AND
`horde_prefs`.`pref_name` LIKE 'identities'",
mysql_real_escape_string($new_data_serial));
$result2 = mysql_query($query);
}
And it works.
I don't know where is the mistake.
Thanks.
More information about the bugs
mailing list