Sunday, October 12, 2014

Change database URLs may damage you site !

Every PHP developer especially  Wordpress developer facing this fact 'We changed our domain name !', the client(site owners) never mind what are the effects that will happen when the site Url change,only developers have to do adjustments to fix all bad effects.
Wordpress as CMD (Content Management System) uses serialized arrays to save options related to themes and other settings.

Every serialized array depend on content (String) and length (Integer) , when you change the URL by find and replace method manually you will change the string but not the length so you will put PHP in aproblem when it will refuse this serialized array and then you will not get the result.

This was my email to my manager , i told him what's happened with me when i was changed the database url manually from the Ubuntu terminal (Shell Commands)

When I was trying to publish the new site from this URL (newsite.hidded.com) to (hidden.com) ,there was a need to change the URLs on the database, so I used the find and replace tool manually .

The result was : a lot of widgets,menus and theme options were missing.

And after hard searching for this problem I found that : WordPress stores many options as "serialized data", which contains both the string content of things and their length. So when you modify the URL and the length changes, then the serialized data is no longer correct, and PHP rejects it.

So if you want to change database URLs safely you have to use tool like this.

Best Regardes ..

Hussam Hussien 



No comments:

Post a Comment