• Hi guys.

    My question isn’t with Document Revisions itself but with the bulk import script. I ended up having to make several changes to get it to work with WP 3.5, but there’s still something I can’t get working right. Files that I upload through the Document Revisions admin screen work just fine, but if I try to download a file imported through the script, I get a 404 error.

    I see an error in the WordPress logs showing that the path to the file can’t be found. The path looks something like .../uploads/sites/4/documents/documents/2013/...
    So it’s the double “documents” in the path that’s messing up the links.

    I then traced to the database looking at the wp_postmeta tables. Files uploaded through the admin screen have the _wp_attached_file value set to “filename.ext” whereas files uploaded through the script have “documents/filename.ext”.

    I’m guessing somewhere in the plugin, it’s inserting the “documents” slug again, which is where the double path comes from. And that’s where I’m stuck: It seems that attaching the file through the plugin and doing it through the import script use two different methods but I don’t know enough about WordPress to fix it.

    Any ideas? Thanks.

    https://www.ads-software.com/extend/plugins/wp-document-revisions/

Viewing 1 replies (of 1 total)
  • Thread Starter Obfuscated

    (@obfuscated)

    I’ll go ahead and post my solution, in case anyone needs it. Basically ended up writing a MySQL query to fix the document paths in the database:

    update wp_{siteid}_postmeta p
    inner join wp_sitemeta s
        on p.meta_value REGEXP concat('^', s.meta_value, '/.*')
        and s.meta_key = 'document_slug'
        and p.meta_key = '_wp_attached_file'
    set p.meta_value = substring(p.meta_value, length(s.meta_value)+2);

    This query assumes you’re running multi-site so replace the {siteid} in the query with the ID for your site.

    I didn’t say it was a good solution. ?? Still would be nice to have a working import script though.

Viewing 1 replies (of 1 total)
  • The topic ‘Can't Download Files Imported With Bulk Import Script’ is closed to new replies.