Summary | Problems with serialized arrays stored in a MySQL DB |
Queue | Horde Base |
Queue Version | 3.3.8 |
Type | Bug |
State | Not A Bug |
Priority | 1. Low |
Owners | |
Requester | steffen.hau (at) rz (dot) uni-mannheim (dot) de |
Created | 09/20/2010 (5400 days ago) |
Due | |
Updated | 10/19/2010 (5371 days ago) |
Assigned | |
Resolved | 09/21/2010 (5399 days ago) |
Github Issue Link | |
Github Pull Request | |
Milestone | |
Patch | No |
I've added something like
$string = preg_replace('!s:(\d+):"(.*?)";!se',
"'s:'.strlen('$2').':\"$2\";'", $string);
before each occurence of unseralize in Horde's code. Now each
serialized array gets correctly unserialized.
Wouldn't it be possible to add a helper function horde_unserialize as
a wrapper for the php unserialize function which does sanitize the
returned serialized arrays from the database tables? I'm wondering why
no other people out there were running into this issue if they use
opensuse.
Best regards,
Steffen
State ⇒ Not A Bug
http://www.horde.org/mail/ contains a list of all available mailing lists.
Priority ⇒ 1. Low
Patch ⇒ No
Milestone ⇒
Queue ⇒ Horde Base
Summary ⇒ Problems with serialized arrays stored in a MySQL DB
Type ⇒ Bug
State ⇒ Unconfirmed
5.0.67 (OpenSUSE 11.1). The development system has PHP 5.3.3 and the
MySQL on the DB server is 5.1.46 (both OpenSUSE 11.3). I've created a
utf8 dumpfile of the old database with phpmyadmin, changed the CHARSET
to utf8 and imported it on the new DB server.
If I now login to the development horde, the identities aren't
displayed at all. The reason for this is the php unserialize function,
which reports an error at offset... It complains about the string
length of "Standardidentität", which was previously 17 and now with
utf8 it is 18. In the manual of unserialize at php.net
(http://www.php.net/manual/de/function.unserialize.php#75773) there
are a couple of comments for this issue and I was able to fix to the
wrong string length for the utf8 thing with php's preg_replace function.
But the identities are still not displayed for those users, which have
a signature or some alias adresses, e.g. configured. There are several
occurrences of "\r\n" in my dumpfilere. If I apply my preg_replace
function on a serialized array returned by MySQL, the result differs
from applying the function to the accordant line on my dumpfile. E.g.
the strlen functions reports a string length of 495 for my signature
fetched from the database, but according to my dumpfile, the string
length of my signature is 527. This results again in an error at
offset.. reported by unserialize.
Is there any documented way on how I could first migrate the db from
latin1 to utf8 as well as having all these serialized arrays beeing
transformed, so that they are still usable?