Title: [Plugin: WordPress Importer] Missing Serialized Meta Value
Last modified: August 20, 2016

---

# [Plugin: WordPress Importer] Missing Serialized Meta Value

 *  Resolved [Valentin](https://wordpress.org/support/users/miplugs/)
 * (@miplugs)
 * [14 years, 2 months ago](https://wordpress.org/support/topic/plugin-wordpress-importer-missing-serialized-meta-value/)
 * Hi,
 * The importer worked just fine, but it missed a custom theme’s (custom post type)
   meta key value that is stored as an PHP array (serialized by WordPress).
 * Here’s the XML file:
 *     ```
       <wp:postmeta>
       			<wp:meta_key>_custom_info</wp:meta_key>
       			<wp:meta_value><![CDATA[a:20:{s:6:"data";...more data...;}]]></wp:meta_value>
       		</wp:postmeta>
       ```
   
 * After I imported the file, in the database the ‘_custom_info’ meta_value was 
   empty.
 * All other custom fields that containted only numbers are fine.
 * Now when I looked at the XML file again I see that a meta key ‘_menu_item_classes’
   is also serialized, but it’s fine in the database.
 * Here is my array that is being stored as a custom field:
 *     ```
       array
         's1' => string '1' (length=1)
         's2' => string '123' (length=3)
         's3' =>
           array
             'asd1' => string 'sss' (length=3)
             'asd2' => string 'sss' (length=3)
             'asd3' => string 'sss' (length=3)
             'asd4' => string 'sss' (length=3)
             'asd5' => string 'sss' (length=3)
             'asd6' => string 'sss' (length=3)
         's4' => string 'sss' (length=3)
       ```
   
 * [http://wordpress.org/extend/plugins/wordpress-importer/](http://wordpress.org/extend/plugins/wordpress-importer/)

Viewing 7 replies - 1 through 7 (of 7 total)

 *  [Jon Cave](https://wordpress.org/support/users/duck_/)
 * (@duck_)
 * [14 years, 2 months ago](https://wordpress.org/support/topic/plugin-wordpress-importer-missing-serialized-meta-value/#post-2577907)
 * I just tested it with the following post meta:
 *     ```
       <wp:postmeta>
         <wp:meta_key>_custom_meta</wp:meta_key>
         <wp:meta_value><![CDATA[a:4:{s:5:"keyed";s:4:"with";s:7:"strings";s:3:"not";s:4:"with";s:6:"digits";s:4:"look";a:2:{i:0;s:8:"subarray";i:1;s:2:"yo";}}]]></wp:meta_value>
       </wp:postmeta>
       ```
   
 * and it all worked fine. Automated tests also exist which test serialized meta
   being imported, so I don’t think it’s caused by the serialization alone.
 * Could you paste some unedited post meta that didn’t import? If a lot of text 
   then use a pastebin like pastie.org.
 * Are you using the latest version of the importer (0.5.2 at time of writing)?
 *  Thread Starter [Valentin](https://wordpress.org/support/users/miplugs/)
 * (@miplugs)
 * [14 years, 2 months ago](https://wordpress.org/support/topic/plugin-wordpress-importer-missing-serialized-meta-value/#post-2577919)
 * Yes, I have the latest version of the importer.
 * [http://pastebin.com/0FSBNhet](http://pastebin.com/0FSBNhet)
 *  [Jon Cave](https://wordpress.org/support/users/duck_/)
 * (@duck_)
 * [14 years, 2 months ago](https://wordpress.org/support/topic/plugin-wordpress-importer-missing-serialized-meta-value/#post-2577950)
 * The importer attempts to use two different XML parsers included in PHP, but has
   a fallback to a regular expression based parser (yuck!). I tracked the issue 
   down to this regex parser doing something funny to serialized values, but I’m
   not sure exactly why yet as it only seems to affect some meta values as you noticed.
   I’ll try to get a fix out soon.
 * Thanks for the report 🙂
 *  [Jon Cave](https://wordpress.org/support/users/duck_/)
 * (@duck_)
 * [14 years, 2 months ago](https://wordpress.org/support/topic/plugin-wordpress-importer-missing-serialized-meta-value/#post-2577954)
 * If you change line 469 of wordpress-importer/parsers.php from
 *     ```
       $return = $wpdb->escape( trim( $return ) );
       ```
   
 * to
 *     ```
       $return = trim( $return );
       ```
   
 * i.e. remove the call to $wpdb->escape(). It should work for you. The entire line
   can probably be commented out too.
 *  Thread Starter [Valentin](https://wordpress.org/support/users/miplugs/)
 * (@miplugs)
 * [14 years, 2 months ago](https://wordpress.org/support/topic/plugin-wordpress-importer-missing-serialized-meta-value/#post-2577958)
 * Thanks for the fix!
 * Any idea when the fix will be added to the offical release?
 *  [Jon Cave](https://wordpress.org/support/users/duck_/)
 * (@duck_)
 * [14 years, 2 months ago](https://wordpress.org/support/topic/plugin-wordpress-importer-missing-serialized-meta-value/#post-2577965)
 * No problem. Probably tomorrow if not later today.
 *  [marikamitsos](https://wordpress.org/support/users/marikamitsos/)
 * (@marikamitsos)
 * [14 years, 2 months ago](https://wordpress.org/support/topic/plugin-wordpress-importer-missing-serialized-meta-value/#post-2578267)
 * Hello Jon
 * > Jon Cave | Administrator | Posted 1 week ago #
   >  No problem. Probably tomorrow
   > if not later today.
 * I just updated to v.0.5.2 but the fix is NOT there.
    Is it because it doesn’t
   work that well and needs further testing? Should we also do this change as well(
   we have custom posts too)?
 * Thanks

Viewing 7 replies - 1 through 7 (of 7 total)

The topic ‘[Plugin: WordPress Importer] Missing Serialized Meta Value’ is closed
to new replies.

 * ![](https://ps.w.org/wordpress-importer/assets/icon.svg?rev=2791650)
 * [WordPress Importer](https://wordpress.org/plugins/wordpress-importer/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/wordpress-importer/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/wordpress-importer/)
 * [Active Topics](https://wordpress.org/support/plugin/wordpress-importer/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/wordpress-importer/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/wordpress-importer/reviews/)

 * 7 replies
 * 3 participants
 * Last reply from: [marikamitsos](https://wordpress.org/support/users/marikamitsos/)
 * Last activity: [14 years, 2 months ago](https://wordpress.org/support/topic/plugin-wordpress-importer-missing-serialized-meta-value/#post-2578267)
 * Status: resolved