[wp-testers] Attachment serialization and migration

Andy Skelton skeltoac at gmail.com
Sat Feb 25 01:36:43 GMT 2006


On 2/24/06, Ryan Scheuermann <ryan at concept64.com> wrote:
> I exported the MySQL database as SQL, made the appropriate changes to
> reflect the server name change and file structure changes. Etc etc.
> Everything works, presto. Except for one thing: when the
> inline-uploading.php is calling |get_post_meta| for the attachments -
> the function |maybe_unserialize|) (calling PHP's |unserialize|) doesn't
> unserialize the string of meta data in the DB as an array. It comes out
> as a string and messes the inline uploading up.
>
> I figure this has something to do with how I export the SQL and then
> reexecute the SQL statements on the server database. Is there some way I
> can fix this without re-uploading every file through the inline
> uploading form?

I'm not positive but I can relate this to another situation where some
characters had slashes added or removed prior to unserialize(), which
changes the byte counts and causes unserialize() to fail. The only way
I discovered that was by counting the bytes and comparing the result
against the numbers in the serialized string.

a:2:{i:0;s:5:"foo's";i:1;s:5:"bar's";}
a:2:{i:0;s:6:"foo\'s";i:1;s:6:"bar\'s";}

a:2:{i:0;s:6:"foo's";i:1;s:6:"bar's";}
a:2:{i:0;s:5:"foo\'s";i:1;s:5:"bar\'s";}

The first two are valid. The second two will fail to unserialize.

It could be something else, but check for that.

Andy


More information about the wp-testers mailing list