Skip to content
This repository has been archived by the owner on Feb 1, 2019. It is now read-only.

Serialized custom field data is not imported correctly after being exported by the standard WordPress export/import plugin #70

Open
Scotchester opened this issue Aug 27, 2015 · 2 comments
Assignees

Comments

@Scotchester
Copy link
Contributor

This is probably not a bug specific to CMS Toolkit, but I couldn't think of a better place to put it.

Example:

The milestone meta_value is stored in an array of strings:


"milestones": [
  "Determine how much you can afford to spend on a home",
  "Decide if it’s the right time to buy a new home",
  "Gather your application paperwork"
],

This data is exported to WordPress's XML format in a serialized form, like so:

…
<wp:postmeta>
    <wp:meta_key>milestones</wp:meta_key>
    <wp:meta_value><![CDATA[a:3:{i:0;s:52:"Determine how much you can afford to spend on a home";i:1;s:50:"Decide if it’s the right time to buy a new home ";i:2;s:34:"Gather your application paperwork ";}]]></wp:meta_value>
</wp:postmeta>
…

After attempting to import into a different WordPress installation, the JSON output for the field shows:


"milestones": [
  "a:0:{}",
  "a:3:{i:0;s:52:\"Determine how much you can afford to spend on a home\";i:1;s:50:\"Decide if it’s the right time to buy a new home \";i:2;s:34:\"Gather your application paperwork \";}"
],

For some reason, the data is not being correctly unserialized. It could be being exported incorrectly, imported incorrectly, or both.

Things we've tried:

  • Using WP-CLI to export and import the data. WP-CLI definitely doesn't export it correctly. It shows an empty serialized array:

    wp:postmeta
    wp:meta_keymilestones/wp:meta_key
    wp:meta_value/wp:meta_value
    /wp:postmeta

  • Adding a maybe_unserialize() call to the line in the import plugin's parser that sets meta values. Appears to have no effect.

I think the next step is a full step-by-step debugging of the import process.

@Scotchester
Copy link
Contributor Author

/cc @cfarm @virginiacc @amymok

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants