6.0.0-alpha14
7/2/25

[#10245] Identities values disappear after an upgrade from H3
Summary Identities values disappear after an upgrade from H3
Queue IMP
Queue Version Git master
Type Bug
State Not A Bug
Priority 2. Medium
Owners
Requester laurent.foucher (at) iut-tlse3 (dot) fr
Created 06/14/2011 (5132 days ago)
Due
Updated 06/30/2011 (5116 days ago)
Assigned 06/29/2011 (5117 days ago)
Resolved 06/30/2011 (5116 days ago)
Github Issue Link
Github Pull Request
Milestone
Patch No

History
06/30/2011 02:23:00 PM sistemisti-posta (at) csi (dot) it Comment #9 Reply to this comment
I have the same problem.
After migration I can't see identities.
I followed the horde docs/UPGRADING#new-database-migrations
06/30/2011 01:49:54 PM Jan Schneider Comment #8
State ⇒ Not A Bug
Reply to this comment
In fact, i have a problem with encoding. Before migration, as 
recommended, i'm converting the database from latin1 to utf8 like 
this :
So, you're messing with the data format and then file a bug if the 
migration doesn't work anymore? This isn't recommended anywhere and 
it's going to blow up your database.
06/30/2011 01:28:33 PM laurent (dot) foucher (at) iut-tlse3 (dot) fr Comment #7 Reply to this comment
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.
06/29/2011 04:44:16 PM Jan Schneider Comment #6 Reply to this comment
It the upgrade task run at all?
06/29/2011 04:22:58 PM laurent (dot) foucher (at) iut-tlse3 (dot) fr Comment #5 Reply to this comment
Just done some more tests. After upgrading from horde3, and after a 
first login, the identities are not available. I have this value store 
in horde_prefs :

pref_uid : laurent.foucher
pref_scope : horde
pref_name : identities
pref_value : a:2:{i:0;a:13:{s:2:"id";s:19:"Identité par 
défaut";s:8:"fullname";s:15:"Laurent 
Foucher";s:9:"from_addr";s:28:"laurent.foucher@iut-tlse3.fr";s:12:"replyto_addr";s:0:"";s:10:"alias_addr";a:0:{}s:10:"tieto_addr";a:0:{}s:8:"bcc_addr";a:0:{}s:9:"signature";s:125:"- Laurent 
Foucher
< I U T 'A'  Paul Sabatier >
laurent.foucher@iut-tlse3.fr
Enseignant/Chargé de mission Systèmes & 
Réseau";s:9:"sig_first";i:0;s:10:"sig_dashes";i:1;s:14:"save_sent_mail";i:1;s:16:"sent_mail_folder";s:9:"sent-mail";s:16:"default_identity";s:1:"0";}i:1;a:13:{s:16:"default_identity";s:1:"0";s:2:"id";s:13:"Identité 
Test";s:8:"fullname";s:2:"LF";s:9:"from_addr";s:28:"laurent.foucher@iut-tlse3.fr";s:12:"replyto_addr";s:28:"laurent.foucher@iut-tlse3.fr";s:10:"alias_addr";a:0:{}s:10:"tieto_addr";a:0:{}s:8:"bcc_addr";a:0:{}s:9:"signature";s:0:"";s:10:"sig_dashes";i:1;s:9:"sig_first";i:1;s:14:"save_sent_mail";i:1;s:16:"sent_mail_folder";s:4:"Sent";}}


logout, apply my script and the identities are now available. The 
value store in the database is :

pref_value : a:2:{i:0;a:16:{s:2:"id";s:21:"Identité par 
défaut";s:8:"fullname";s:15:"Laurent 
Foucher";s:9:"from_addr";s:28:"laurent.foucher@iut-tlse3.fr";s:12:"replyto_addr";s:0:"";s:10:"alias_addr";a:0:{}s:10:"tieto_addr";a:0:{}s:8:"bcc_addr";a:0:{}s:9:"signature";s:128:"- Laurent 
Foucher
< I U T 'A'  Paul Sabatier >
laurent.foucher@iut-tlse3.fr
Enseignant/Chargé de mission Systèmes & 
Réseau";s:9:"sig_first";i:0;s:10:"sig_dashes";i:1;s:14:"save_sent_mail";i:1;s:16:"sent_mail_folder";s:9:"sent-mail";s:16:"default_identity";s:1:"0";s:10:"identities";s:6:"a:0:{}";s:10:"properties";s:0:"";s:8:"location";s:0:"";}i:1;a:13:{s:16:"default_identity";s:1:"0";s:2:"id";s:14:"Identité 
Test";s:8:"fullname";s:2:"LF";s:9:"from_addr";s:28:"laurent.foucher@iut-tlse3.fr";s:12:"replyto_addr";s:28:"laurent.foucher@iut-tlse3.fr";s:10:"alias_addr";a:0:{}s:10:"tieto_addr";a:0:{}s:8:"bcc_addr";a:0:{}s:9:"signature";s:0:"";s:10:"sig_dashes";i:1;s:9:"sig_first";i:1;s:14:"save_sent_mail";i:1;s:16:"sent_mail_folder";s:4:"Sent";}}

06/29/2011 03:34:17 PM Jan Schneider Comment #4 Reply to this comment
it's seems that this call doesn't append the missing values   
identities, properties and location.
Not sure what you mean with that.
06/29/2011 03:26:09 PM laurent (dot) foucher (at) iut-tlse3 (dot) fr Comment #3 Reply to this comment
it's seems that this call doesn't append the missing values   
identities, properties and location.
06/29/2011 02:04:21 PM Jan Schneider Comment #2
State ⇒ Feedback
Reply to this comment
This already happens in 
Horde_LoginTasks_SystemTask_Upgrade::_upgradePrefs() resp. 
Horde_Core_Prefs_Storage_Upgrade::upgradeSerialized().
06/14/2011 02:32:39 PM laurent (dot) foucher (at) iut-tlse3 (dot) fr Comment #1
Milestone ⇒
State ⇒ Unconfirmed
Patch ⇒ No
Queue ⇒ IMP
Summary ⇒ Identities values disappear after an upgrade from H3
Type ⇒ Bug
Priority ⇒ 2. Medium
Reply to this comment
Hi,

Upgrading from Horde3 to horde4, the identities values are no more 
considered. To fix this, i have this little script :

$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)) {
         $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[0]['identities'] = 'a:0:{}';
         $new_data[0]['properties'] = '';
         $new_data[0]['location'] = '';

         $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));

......

I have only had the keys identities, properties and location in the 
horde_prefs.

Maybe could be integrated in the systemlogintask.

Thanks

Saved Queries