Title: serialization when moving a site, explained?
Last modified: August 20, 2016

---

# serialization when moving a site, explained?

 *  [justinwhall](https://wordpress.org/support/users/jwind/)
 * (@jwind)
 * [13 years, 9 months ago](https://wordpress.org/support/topic/serialization-when-moving-a-site-explained/)
 * When I first started working with WordPress, I did what many others do. Work 
   locally on MAMP and then move to an actual live environment. I would dump the
   database, search and replace URLs and then import to the live site.
 * I eventually learned that is no good due to serialization issues so I started
   using the [WP DB script](http://interconnectit.com/124/search-and-replace-for-wordpress-databases/).
 * All well and good, but the thing is, I never had any issues before hand and I
   moved a lot of site like that. Can someone please explain why and how using the
   former method can be a problem?

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

 *  [s_ha_dum](https://wordpress.org/support/users/apljdi/)
 * (@apljdi)
 * [13 years, 9 months ago](https://wordpress.org/support/topic/serialization-when-moving-a-site-explained/#post-2971449)
 * If you look carefully at a serialized array or object you will notice that some
   of the values in the serialized string represent the length of the other values
   in the string. For example:
 *     ```
       array(2) {
         [0]=>
         string(4) "bird"
         [1]=>
         string(3) "dog"
       }
       a:2:{i:0;s:4:"bird";i:1;s:3:"dog";}
       ```
   
 * Notice the number immediately preceding the animal type? That is a count of the
   characters in that value. Also, notice the ‘s’ before preceding the number. That
   is the type– string. If you search and replace a serialized array, it may not
   unserialize correctly because those values don’t match the string they are supposed
   to refer to. For example:
 *     ```
       $s = 'a:2:{i:0;s:4:"bird";i:1;s:3:"dog";}';
       var_dump(unserialize($s));
   
       $s = 'a:2:{i:0;s:4:"falcon";i:1;s:3:"dog";}';
       var_dump(unserialize($s));
   
       $s = 'a:2:{i:0;s:8:"bird";i:1;s:3:"dog";}';
       var_dump(unserialize($s));
       ```
   
 * The first is correct and will unserialize to the same array as we started with.
   They other two, which I have edited carelessly, unserialize to `false`. The are
   just strings though, and if you know what you are doing you can edit them. This
   will unserialize correctly because I edited both the value and the ‘length’:
 *     ```
       $s = 'a:2:{i:0;s:6:"falcon";i:1;s:3:"dog";}';
       var_dump(unserialize($s));
       ```
   
 *  Thread Starter [justinwhall](https://wordpress.org/support/users/jwind/)
 * (@jwind)
 * [13 years, 9 months ago](https://wordpress.org/support/topic/serialization-when-moving-a-site-explained/#post-2971575)
 * Got it. I think. So the problem is really, for instance, a URL to an image that
   is stored within an array.
 * URL one may be 10 characters long…
    URL two is 12 characters long…
 *  [s_ha_dum](https://wordpress.org/support/users/apljdi/)
 * (@apljdi)
 * [13 years, 9 months ago](https://wordpress.org/support/topic/serialization-when-moving-a-site-explained/#post-2971593)
 * Any URL, not just for an image, and don’t forget that it break the entire serialize
   string not just part of it.

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

The topic ‘serialization when moving a site, explained?’ is closed to new replies.

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 3 replies
 * 2 participants
 * Last reply from: [s_ha_dum](https://wordpress.org/support/users/apljdi/)
 * Last activity: [13 years, 9 months ago](https://wordpress.org/support/topic/serialization-when-moving-a-site-explained/#post-2971593)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
