wp make-wxr

As part of my day job, I’ve lately been looking at trying to improve the performance of WXR imports into WordPress.com. This has meant, so far, lots of testing and profiling of code, and it’s meant my wanting to be able to generate export files that meet particular criteria.

For example, one useful test is to repeatedly import a file that contains 1,000 posts so that you wind up with a benchmark for how long it takes on average to pull in that many posts (so that you can try to make that number consistently lower). Not everybody has a test site with exactly 1,000 posts in it, and it’s sure no fun to manually generate that test data.

For another example, say you’re trying to understand what impact taxonomies have on import sluggishness. The WXR file lists tags and categories near the top of the file and imports them all at the beginning of the process. Then it associates terms with posts as it imports the posts later. In order to understand how the taxonomy import performs, it’d be useful to have a WXR file with exactly 500 tags for that initial import, with a few randomly assigned to the posts.

And say you wanted to learn how comments get bogged down. It’d be handy to be able to easily import a single post that had a great many comments, or to import many posts with either few or many comments each.

Enter make-wxr, a wp-cli command I wrote to help me generate just these sorts of WXR files on demand. Now, by typing a simple command into my terminal, I can instantly have a reasonably customized WXR file for testing various trouble spots in the WordPress importer.

After some initial skepticism, I only recently started using wp-cli as part of a big data migration, and now I’m a pretty big fan of the tool. My little command here is just a brand new baby, conceived and born within the last couple of hours. I already have some ideas for improvements (though probably not much time to implement them, since the itch I was scratching by writing this is now scratched). If you’re a developer who works with debugging WordPress with data of varying sizes and characteristics, maybe the new command will be useful. (If you’re a theme developer, you should use the standard WXR file, since it covers lots of test cases like long titles, menus, etc.)

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s