WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] WordPress Importer Tries to save media files to wrong site folder (14 posts)

  1. purcell
    Member
    Posted 10 months ago #

    I am importing from one WordPress multisite instance to another. I receive the "Failed to import media" message for all files.

    When I look at the apache log I get:

    [Wed Nov 13 11:05:30 2013] [error] [client 10.11.1.13] client denied by server configuration: /var/vhosts/wordpress/html/wp-content/uploads/sites/10, referer: http://drawyourweapons.wordpress.drake.edu/

    The path on the test server I am importing from is: /var/vhosts/wordpress-test/html/wp-content/uploads/sites/10

    The path to the new site on the production server is: /var/vhosts/wordpress/html/wp-content/uploads/sites/6

    I do not understand why it is trying to get to that site on prod

  2. purcell
    Member
    Posted 10 months ago #

    To clarify: I am generating a wxr file using Tools -> export and then importing it with Tools -> import

  3. These are different servers, right? And different domains?

    You're not actually trying to import from a separate site on the same domain.network are you?

  4. purcell
    Member
    Posted 10 months ago #

    These are two different servers on the same drake.edu domain. I am trying to import from the test server at wordpress-test.drake.edu to wordpress.drake.edu.

  5. Ah! Okay thanks :)

    Grab your server admin (if it's not you) and ask if wordpress-test.drake.edu is blocking connections from other servers. That's the most likely error.

    A possible workaround would be to import content, but NOT import images. Then just copy the images over manually to the new location and search/replace your text for wordpress-test/wordpress

  6. purcell
    Member
    Posted 10 months ago #

    Sysadmin checked and there shouldn't be anything blocking connections from other servers and nothing in the logs.

    I actually have a couple of sites I need to move between servers that need to have their media library properly imported, any suggestions would be greatly appreciated. Thanks a ton for your responses.

  7. Like I said:

    A possible workaround would be to import content, but NOT import images. Then just copy the images over manually to the new location and search/replace your text for wordpress-test/wordpress

  8. dramaley
    Member
    Posted 9 months ago #

    I've created a patch that will work around this issue. This patch is for WordPress 3.6.1. It is a hack, not something that should be taken very seriously except that it points out where the problem may be. I don't know PHP, but was able to trace it back to this point before giving up. I expect someone with more familiarity with the WordPress code base could figure out what the problem is once they see the patch and see what code is being modified.

    I did notice that the code is doing a lot of checks against the IP of the remote server. I'm not sure the justification for checking whether the remote server is on a private network, but that may be part of the issue. The server we exported from is on 10.10.2.16, while the server we import on is 10.10.1.206. Both are on the same private network.

    The patch is available here: http://pastebin.com/LeVtWKhX

  9. DO NOT EDIT CORE FILES

    Seriously just no.

    if ( ! apply_filters( 'http_request_host_is_external', false, $host, $url ) )
                                           return false;

    and

    if ( ! apply_filters( 'http_request_host_is_external', false, $host, $url ) )
                                         return false;

    are the same... What did you think you were changing?

  10. dramaley
    Member
    Posted 9 months ago #

    The lines in my patch are not the same; you omitted the "//" at the beginning of the second set. Obviously "diff" would not have flagged them as being different if they were in fact the same.

    And yes, i know core files shouldn't be edited. But that's as far back as i was able to trace the error. I'm not suggesting my patch be implemented, just using a patch to point out where exactly the problem seems to be. I'm assuming that patch will break something else. But, it does at least allow the importer to work correctly!

  11. Oh *sqint* Pastebin needs better font sizes. Okay, good. You can do this WITHOUT editing core.

    Put this in an mu-plugin:

    add_filter( 'http_request_host_is_external', '__return_true' );

    Read http://wordpress.stackexchange.com/a/123313/7886 for the whole answer, and why you don't want to leave this around forever.

  12. DFieldFL
    Member
    Posted 9 months ago #

    I have created a plugin that lets you specific the hosts you want to communicate with in the wp-admin settings. Check it out: http://wordpress.org/plugins/wp-allow-hosts/

  13. dramaley
    Member
    Posted 9 months ago #

    The wp-allow-hosts plugin looks very helpful. I'm still not sure i understand the rationale for the "feature" that blocks downloads when doing an import, but the next time we have to do an import i will definitely give your plugin a try. Thanks!

  14. DFieldFL
    Member
    Posted 9 months ago #

    I could be completely off base but I think it blocks internal host spoofing. Anyways next time you need it give it a try and comment if you see anything that needs to be fixed. Thanks.

Reply

You must log in to post.

About this Topic