{"id":3077,"date":"2016-02-11T11:17:47","date_gmt":"2016-02-11T11:17:47","guid":{"rendered":"http:\/\/www.simonbattersby.com\/blog\/?p=3077"},"modified":"2016-08-18T14:22:28","modified_gmt":"2016-08-18T13:22:28","slug":"page-builder-data-lost-after-migration","status":"publish","type":"post","link":"https:\/\/www.simonbattersby.com\/blog\/2016\/02\/page-builder-data-lost-after-migration\/","title":{"rendered":"Page Builder data lost after migration"},"content":{"rendered":"<p>I&#8217;ve spent a lot of time this morning looking into an issue with a client site migration where Page Builder data was lost after the migration.<\/p>\r\n<p>I have migrated many many WordPress sites by exporting the database, replacing the old URL with the new URL in the exported SQL and re-importing. Never had an issue. But in this case I did, and it&#8217;s related to how Page Builder stores data. This data is <em>serialized<\/em>, and the serialization stores both the data and its length. So a snippet of stored data looks like this:<\/p>\r\n<pre>s:<span class=\"code_highlight\">160<\/span>:\"&lt;p&gt;&lt;img class=\"alignleft size-full wp-image-2348\" src=\"http:\/\/<span class=\"code_highlight\">test.co.uk<\/span>\/wp-content\/uploads\/2014\/05\/Tulips.jpg\" alt=\"Tulips\" width=\"200\" height=\"150\" \/&gt;&lt;\/p&gt;\"<\/pre>\r\n<p>Super&#8230;so if you run a global replace on the domain name you end up with this:<\/p>\r\n<pre>s:<span class=\"code_highlight\">160<\/span>:\"&lt;p&gt;&lt;img class=\"alignleft size-full wp-image-2348\" src=\"http:\/\/<span class=\"code_highlight\">production.co.uk<\/span>\/wp-content\/uploads\/2014\/05\/Tulips.jpg\" alt=\"Tulips\" width=\"200\" height=\"150\" \/&gt;&lt;\/p&gt;\"<\/pre>\r\n<p>Which looks fine, but it isn&#8217;t because the serialization is now incorrect as the length of the serialized string has changed from 160 characters to 166 characters. Result: lost Page Builder data.<\/p>\r\n<p>The correct update should be:<\/p>\r\n<pre>s:<span class=\"code_highlight\">166<\/span>:\"&lt;p&gt;&lt;img class=\"alignleft size-full wp-image-2348\" src=\"http:\/\/<span class=\"code_highlight\">production.co.uk<\/span>\/wp-content\/uploads\/2014\/05\/Tulips.jpg\" alt=\"Tulips\" width=\"200\" height=\"150\" \/&gt;&lt;\/p&gt;\"<\/pre>\r\n<p>Clearly doing this is impracticable and fortunately there&#8217;s a plugin that handles this which is <a href=\"https:\/\/wordpress.org\/plugins\/wp-migrate-db\/\">WP Migrate DB<\/a>.<\/p>\r\n\r\n\r\n\r\n\r\n","protected":false},"excerpt":{"rendered":"<p>I&#8217;ve spent a lot of time this morning looking into an issue with a client site migration where Page Builder data was lost after the migration. I have migrated many many WordPress sites by exporting the database, replacing the old URL with the new URL in the exported SQL and re-importing. Never had an issue. [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3],"tags":[10],"class_list":["post-3077","post","type-post","status-publish","format-standard","hentry","category-web-design-and-build","tag-wordpress"],"_links":{"self":[{"href":"https:\/\/www.simonbattersby.com\/blog\/wp-json\/wp\/v2\/posts\/3077","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.simonbattersby.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.simonbattersby.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.simonbattersby.com\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.simonbattersby.com\/blog\/wp-json\/wp\/v2\/comments?post=3077"}],"version-history":[{"count":3,"href":"https:\/\/www.simonbattersby.com\/blog\/wp-json\/wp\/v2\/posts\/3077\/revisions"}],"predecessor-version":[{"id":3080,"href":"https:\/\/www.simonbattersby.com\/blog\/wp-json\/wp\/v2\/posts\/3077\/revisions\/3080"}],"wp:attachment":[{"href":"https:\/\/www.simonbattersby.com\/blog\/wp-json\/wp\/v2\/media?parent=3077"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.simonbattersby.com\/blog\/wp-json\/wp\/v2\/categories?post=3077"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.simonbattersby.com\/blog\/wp-json\/wp\/v2\/tags?post=3077"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}