Improve speed of import when uploads are available locally
Feature Request
- [x] Yes, I reviewed the contribution guidelines.
Describe your use case and the problem you are facing
I am importing a site with almost 4GB of media and almost 10,000 posts and it takes longer than I'd like.
Describe the solution you'd like
Potential solutions:
- Check to see if file exists in
wp-content/uploads/already. If it does, use it instead of fetching it- To be fast this would need to be naive (matching only file name) and should probably only be enabled with an option
- As above, but using
--source-dir=or similar option - Allow attachements to be imported with
file://URLs.- Currently,
file://URLs result in errors like:Failed to import Media “media_name”: Request failed due to an error: A valid URL was not provided. (http_request_failed)<br />- The error remains when the
http_request_host_is_externalis updated to be__return_true
- The error remains when the
- Currently,
Thanks for the suggestion, @TimidRobot !
This sounds like a great idea. We'd want to make it an opt-in behavior via flag or something similar. Here's another approach I've used in the past: https://danielbachhuber.com/two-wordpress-migration-performance-tips/
Feel free to submit a pull request, if you'd like. Here is some guidance on our pull request best practices.
@danielbachhuber thank you for the link!
The method we're currently using is:
- Copy
wp-content/uploads/from source using rsync - Modify web hosting to serve the copy
- Modify the WXR attachment URLs so they reference localhost (where the local web host is serving the copy)
- Temporarily modify
http_request_host_is_externalto be__return_trueto allow localhost URL during import
This seems to have largely removed the attachment portion of the import as a performance bottleneck for us. However it's a solution that is very specific, complex, and unattainable in a lot of hosting environments.