You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm attempting to copy media from my production site ("https://example.com") to my staging site on a different server ("https://stage.example.com"), using the "wp import" CLI tool.
The error message I got was very unclear at first - literally just "Failed to import Media" and the filename without any other information about what went wrong. If you search the "Support" history for this plugin, you see a ton of people asking for help relating to this error message.
Reading through the source code, I realized I could get more information by setting the IMPORT_DEBUG value to true. This told me that a valid URL was not being passed, which again was a little confusing because the URL is present in the XML file.
Further print line debugging made me realize that the issue is in wp_http_validate_url, which compares the URL for get_option('home') - in my case, the staging server - with the external URL - the production server. If these don't match, the media import will fail. I could imagine a lot of different reasons that you would want to import from a different URL externally, so it might be good to have an option to turn this flag off.
I tried setting the --url flag to wp import but this did not seem to have any effect.
In addition to making it possible to import from a URL with a different hostname than the value in get_option('home') it might be nice to improve the error message, or at least include more troubleshooting information to help people without the time or the means to go spelunking in the source code to figure out how to answer their problem.
The text was updated successfully, but these errors were encountered:
Yes, "wp import" invokes this plugin. I'm not sure exactly of the mechanism, but if I add print statements to the source code for this plugin, and then run "wp import", the print statements appear in the output.
I'm attempting to copy media from my production site ("https://example.com") to my staging site on a different server ("https://stage.example.com"), using the "wp import" CLI tool.
The error message I got was very unclear at first - literally just "Failed to import Media" and the filename without any other information about what went wrong. If you search the "Support" history for this plugin, you see a ton of people asking for help relating to this error message.
Reading through the source code, I realized I could get more information by setting the IMPORT_DEBUG value to true. This told me that a valid URL was not being passed, which again was a little confusing because the URL is present in the XML file.
Further print line debugging made me realize that the issue is in
wp_http_validate_url
, which compares the URL forget_option('home')
- in my case, the staging server - with the external URL - the production server. If these don't match, the media import will fail. I could imagine a lot of different reasons that you would want to import from a different URL externally, so it might be good to have an option to turn this flag off.I tried setting the
--url
flag towp import
but this did not seem to have any effect.In addition to making it possible to import from a URL with a different hostname than the value in
get_option('home')
it might be nice to improve the error message, or at least include more troubleshooting information to help people without the time or the means to go spelunking in the source code to figure out how to answer their problem.The text was updated successfully, but these errors were encountered: