• Resolved Josh Maxwell

    (@hornetok)


    First off, I’m on a Windows 2008 box running IIS7 with a web.config file not htaccess.

    That being said, I’ve migrated my old Apache(XAMPP) installed WPMS site over to a new IIS7 server successfully with one glitch: my media files are doing some really funky stuff.

    // The run down:
    I have my main site and about 200+ subsites. Uploading new files to the blogs.dir folder is successful and I’m able to see them on my site just fine afterwards.

    // The funk:
    SOME of my old files, PDF and Word documents only, on my main site are still linked properly. It seems to be only pre-move image files that are affected. The files are still listed in the media library correctly and I can see the files in the directories themselves, but there is still some disconnect between the Library and the directories.

    Caveat: I’ve had to keep my main site’s upload folder set to /wp-content/blogs.dir/1/files/ because my WordPress installation was pre-3.0. This hasn’t been shown to be an issue yet, since I can still see some files. I tried moving it to /wp-content/uploads/, but that seemed to give me more of a headache.

    Here is my web.config file in case someone is able to see some issue within it that’s causing the problem.

    Any help would be greatly appreciated!

Viewing 14 replies - 1 through 14 (of 14 total)
  • Thread Starter Josh Maxwell

    (@hornetok)

    I’ve checked a few things in my database and here’s what I’ve found:

    Under the wp_options table, file_uploadurl = my.domain.com/files/ (or in the case of subsites, file_uploadurl = my.domain.com/[username]/files/.

    When I visit the Media Library > File Edit, the File URL of all my files is set to my.domain.com/wp-content/blogs.dir/[X]/files/YYYY/MM/file.ext

    Here’s something weird though, when I look at the wp_posts table and look only at the attachments, the pre-move files’ guid = my.domain.com/[username if applicable]/files/YYYY/MM/file.ext This goes for images as well as the PDFs & docs (both of which are working with this url setup).

    Now, when I look at the newer, post-move files, I see guid = my.domain.com/wp-content/blogs.dir/[X]/files/YYYY/MM/file.ext

    But, my file_uploadurl is still set to domain.com/files! What is going on?!?! And HOW do I fix this?

    I tried using the plugin Add From Server: would only allow me upload a new, naturally, and it worked, but it’s not what I need to have happen. Then I found Enable Media Replace, which got me really excited, because you were supposed to be able to replace the image, title, AND location but it would go through and update the links for you. I thought this was perfect! /fail It replaced the image and the title, but the location stayed the same as well as all the links.

    So I’m back to square one πŸ™

    //edit

    Also, all thumbnails of internally hosted files are displaying correctly and all externally hosted images’ thumbnails are broken.

    Thread Starter Josh Maxwell

    (@hornetok)

    Found this post and tried the fix on page 2:

    Tried commenting out the following:
    // define('WP_ALLOW_MULTISITE', true);
    // define( 'MULTISITE', true );

    and was greeted by:

    One or more database tables are unavailable. The database may need to be repaired.

    Still no luck.

    Thread Starter Josh Maxwell

    (@hornetok)

    If I manually change the pre-move files from
    guid = my.domain.com/[username if applicable]/files/YYYY/MM/file.ext
    to
    guid = my.domain.com/wp-content/blogs.dir/[X]/files/YYYY/MM/file.ext
    AND I go back to each post and reattach the image

    Two questions:

    • Any ideas how to easily change the guids sitewide to match up with their blog IDs? Even a site-by-site solution would work and keep me from having to manually update every ‘wp_[X]_posts’ entry individually.

      I think a SQL statement might work, but I’m not for sure.

    • And any ideas how I can update all posts sitewide without having to reattach each image individually?
    Thread Starter Josh Maxwell

    (@hornetok)

    The Search & Replace plugin helped me get going on a solution:

    I was able to go through and change all the URL references from
    my.domain.com/[username]/files/YYYY/MM/file.ext to
    my.domain.com/wp-content/blogs.dir/[X]/files/YYYY/MM/file.ext
    blog by blog.

    After I tried it a few times inside the plugin, I realized I could export my whole database into a SQL file, open it in Notepad++, perform a search for [username]/files and replace all references with wp-content/blogs.dir/[X]/files.

    It took about 2 hours to complete my search & replace. The pre-move images are being displayed properly on the homepages of the sites now.

    Found a hitch though: the thumbnails in the Media Library don’t seem to want to work now. I think the URL rewrite is taking over here though.

    (I don’t think anyone’s reading this, but I’ll keep documenting it for future reference.)

    Moderator Ipstenu (Mika Epstein)

    (@ipstenu)

    πŸ³οΈβ€πŸŒˆ Advisor and Activist

    I’m reading, but since I wasn’t sure, I said nothing πŸ˜‰

    the thumbnails in the Media Library don’t seem to want to work now. I think the URL rewrite is taking over here though.

    Where are the thumbnails pointing to? I wonder if they store that data in the DB as serialized data….

    Thread Starter Josh Maxwell

    (@hornetok)

    Yay! I’m not talking to myself anymore! πŸ˜›

    Where are the thumbnails pointing to?

    They are pointing to: [username]/files/yyyy/mm/file.ext.

    I wonder if they store that data in the DB as serialized data….

    The wp_[x]_posts tables show the URLs in the normal format.

    I’ve been testing the file_uploadurl option with two different blogs: one is set to [username]/files and the other is set to wp-content/blogs.dir/[X]/files. When I upload a new file, BOTH blogs render the same result: the file & thumbnail pointing to [username]/files/yyyy/mm/file.ext, which is why I was thinking maybe it was a URL rewrite issue…

    HOWEVER, when I test this same file on my main site: it is uploading correctly (at least it’s using the file_uploadurl I’ve set it as) and all URLs point to wp-content/blogs.dir/1/files/YYYY/MM/file.ext, so thumbnails and regular images all work properly here.

    esmi

    (@esmi)

    I wonder if they store that data in the DB as serialized data….

    Bearing in mind that I only have single installs to look through, I can only find references to thumbnail dimensions in serialized arrays (wp_postmeta table). Only the urls for the full size images are stored and they’re in plain text in wp_posts. Also had a quick scan through wp-includes/media/php & that supports what I’d always assumed – that the srcs for the thumbs are created dynamically.

    Not sure if that helps any or if you need a ninja here.

    Moderator Ipstenu (Mika Epstein)

    (@ipstenu)

    πŸ³οΈβ€πŸŒˆ Advisor and Activist

    Yeah, I’d email wp-hackers and beg for Ninjas πŸ™

    wp_[x]_posts…. Don’t images also store in wp_[x]_postmeta? (Not on a computer where I can check that right now…_)

    esmi

    (@esmi)

    Yes but only the various image dimensions as far as I can see. No obvious urls.

    Thread Starter Josh Maxwell

    (@hornetok)

    I pointed my wp-config to the “fresh install” database. I kept it in case this sort of thing came up.

    When I upload the same file as with my old database, I get the same results as before*: the main site uploads the file successfully and the image/thumbnail shows up properly; but, when I upload the same file to the subsite, it points to [username]/files/... and is a broken URL.

    I think this might rule out there being a database issue, but I’m not completely for sure…

    If you think about it, both versions were uploading to a “natural” url (non-rewritten) for the main site:

    • Old DB, main site: domain.com/wp-content/blogs.dir/1/files/...
    • New DB, main site: domain.com/wp-content/uploads/files/...

    While the subsites all were rewritten:

    • Old DB, subsite: domain.com/wp-content/blogs.dir/[X]/files/...
    • New DB, subsite: domain.com/[username]/files/...

    This makes me still think I’m having URL rewrite issues for files — and then I remember my PDF files are working with [username]/files.

    I finally was able to get my sysadmin to open the site back up to the public. Here are links to a PDF and an image file I’ve uploaded to my subsite. The PDF link works with & without the URL rewritten while the image only works without.

    If anyone knows of a WordPress-on-IIS Ninja (if such a person exists!), I think we could figure it out.

    * The only difference in situations here is the newer configuration points to the wp-content/uploads and the older configuration points to the blogs.dir/1 dir. I believe this to be mostly irrelevant, though I thought I should point it out.

    Thread Starter Josh Maxwell

    (@hornetok)

    Still no luck.

    How would I get a hold of someone from “wp-hackers”?
    (I don’t think I’ve heard of them)

    Moderator Ipstenu (Mika Epstein)

    (@ipstenu)

    πŸ³οΈβ€πŸŒˆ Advisor and Activist

    Thread Starter Josh Maxwell

    (@hornetok)

    Thanks Ipstenu.

    Progress Update:
    I created a completely separate, fresh WPMS install/set up, created a subsite and all the images, docs, thumbnails, etc, are working properly there. Note: I’m getting to this site via IP address and the other via a domain name.

    After making sure all the settings matched (ie, web.config & wp-config.php) between the working site and the problem site, I’m still no closer to fixing the problem.

    Maybe I’ll try the move again, see if there was just something I missed or a glitch in the installation.

    Thread Starter Josh Maxwell

    (@hornetok)

    Two things, 1) it’s working finally and 2) I’m not sure how I fixed it.

    As I stated in my last comment: I planned to reinstall wordpress yet again and re-setup MultiSite again. Before that, my SysAdmin & I had a chat about some other issues and he made me think about something: usually, on self-hosted solutions, you setup your domain name and where it’ll resolve on the same machine as your WP installation. We have a more complicated setup and the domain names we own are managed from a separate server. Server 2 (domains) point to server 1 (WPMS) … and I had setup server 1 with the domain name to point to itself again. Redundant domain name resolution.

    That may have been the problem, I’m not completely sure. I reinstalled, setup MS and tested the fresh install’s media upload/URLs and it worked. So, I moved my blogs.dir folder over again and pointed the installation back to my old, larger database and that worked, too.

    Conclusion: I’m not completely sure what was broken and what fixed it, all I know is that I’m back in business!

    Thanks for your help, Iptsenu & esmi!

Viewing 14 replies - 1 through 14 (of 14 total)
  • The topic ‘Media Library won't recognize SOME old files after move’ is closed to new replies.