Migration project update

I’ve spent the past few days building functionality for what I’ve termed the “relocate” component — the class that handles site-wide replacement of old URLs with new. A plugin UI is in the work.

Two discoveries were made in the process of coding the relocate component.

  1. Attachment locations have been stored as relative paths since 2.7, which helps with keeping them portable. However, I have seen full paths in the database tables of sites that started up pre-2.7; transitioning those to portable relative paths will be part of what I’m building.
  2. By using WordPress queries and post functions (as opposed to SQL queries) to replace within post content, we gain the advantage of storing those changes in revisions, rather than indiscriminately touching all entries in the posts table in the way that was previously documented on the Codex.

With the guidance of WP CLI’s explanation for how to set up a plugin for testing, I’ve also coded unit tests to verify that things are working as they should. One hurdle I faced in unit testing was that update_option('siteurl') doesn’t affect the value of the WP_CONTENT_URL constant until the next execution of the script, by which time the unit test framework will have rolled back the transaction. This minor quirk won’t translate to real world use, although I’m not sure if I’m satisfied with the way I overcame it.

Finishing the UI for this component is my timeline’s task for this week; it will facilitate a user’s decision to change the site URL to a different domain. I’ll make sure installation/usage instructions are shown by next week.

Happy Canada Day!

#migration-portability, #weekly-update