• Greetings,

    this is a simplified version of the only part of this other thread

    https://wordpress.org/support/topic/sharing-uploads-folder-among-different-blogs?replies=3

    that is still a very “open issue” to me, that is I fear that even if I test it and it seems to work, I have no idea if it would continue to work after the first updates!

    If I create several, independent wordpress blogs, each with its own database, installed side by side under the server root:

    $ROOT/blog1
    $ROOT/blog2
    $ROOT/blog3

    but configure ALL of them, in their wp-config.php, to use as uploads folder the SAME place, that is $ROOT/uploads

    will this corrupt the databases, and therefore the blogs? I mean, what will happen if an image is uploaded by user1 of blog1, what will happen to the databases and media library interfaces/caches whatever… of blog2, blog3?

    1. Will they crash, because they find in there a file that they did not upload?
    2. Will they NOT see that file, just because it was not updated from blog2, blog3?
    3. Something else?

    I want to do this because while they would be independent blogs, they WOULD share a lot of images. So having one upload folder only, that is only one copy of each image, would save a lot of space AND time (you only upload one image once, then it appears in the media library of all the blogs.

Viewing 6 replies - 1 through 6 (of 6 total)
  • An ‘/uploads/’ folder can contain anything at all and the database does not ever care as long as it knows what info to give WordPress in order for an upload to be displayed whenever requested by a browser. And so, the question here is this:

    Can and/or how can a single upload be registered in more than one database?

    ‘Add From Server’ is a plugin that can properly register uploads in a database so the database can know what info to send to WordPress, but I do not know how ‘Add From Server’ will act if something such as ‘$ROOT/uploads’ is at work in wp-config. Also, and even if that does work, I do not know how WordPress would act during the registration process instigated by ‘Add From Server’ if the upload being registered already had its corresponding thumbnails in place as done during a previous registration in a different database. Also, it is logical to believe both sites would first need to have identical settings related to thumbnails and cropping.

    I think it would be safe to try the above to see what happens, but I have no idea what the end result would actually be other than to say there is no reason to believe a previous registration in a different database would be corrupted.

    edit: If you do give ‘Add From Server’ a try, you first need to do the upload manually via FTP/SFTP or whatever, and then use ‘Current Time’ rather than ‘File Time’ within ‘Add From Server’.

    Thread Starter mfioretti

    (@mfioretti)

    “it is logical to believe both sites would first need to have identical settings related to thumbnails and cropping”

    Yes! I had forgotten this detail, but yes, all sites would certainly have identical values for such settings, this is not a problem at all (not for me at least). Wrt this:

    do not know how WordPress would act during the registration process instigated by ‘Add From Server’ if the upload being registered already had its corresponding thumbnails in place… there is no reason to believe a previous registration in a different database would be corrupted.

    I have two comments:

    1. The “Add from Server” plugin carries a big “not updated in 2 years, may no longer be supported” notice, so I’ll try that as very last chance..
    2. After thinking a bit about what you said, **I** expect/imagine that, if there is some problem in a scenario like mine (=each wp install has its own separate database) is not due to “database registration” itself (When php code of blog 1 writes anything to database 1, it has no idea at all of the existence of database 2, and no way to interact with it), nor to file permission issues (it’s always the same user, the http server, that accesses the UPLOAD folder) but at one of these things:
    1. outside all the wordpress blogs, that is http-level caching behaving strangely, or inefficiently, if it has to cache two urls which are actually the same file
    2. wp code that creates thumbnails crashes/misbehave if they already exist
    3. wp code of the media library crashes/misbehave when you open the media library, and there are files on disk, never registered in its own database (because uploaded the first time, by another blog, that is registered in another database)

    So, at the moment I expect that if there is any problem is in case 2.3 above, that is NOT seeing in media library of blog 1 stuff that is not registered/listed in its corresponding database. And going with “Add from server” doesn’t seem a future-proof thing to try, not first at least. Must have a look at the media library code and db structures, like the get_media_item functions, I guess?

    (of course, I will just go ahead, set up everything, see what happens and report, at some point. But I need a couple of free days for this and related stuff, which won’t happen until I release other things. So now I can just prepare myself, asking and studying, 5 minutes at a time)

    The “Add from Server” plugin carries a big “not updated in 2 years, may no longer be supported” notice…

    The size of that notice does grab one’s attention, and I also do take note of those. However, that particular plugin worked fine for me just a few days ago and its Changelog does say this:

    = 3.2.0.3 =
    * PHP 5.4 compatibility
    * Special characters in URL fixes

    http-level caching behaving strangely, or inefficiently, if it has to cache two urls which are actually the same file

    I know nothing about that kind of thing.

    wp code that creates thumbnails crashes/misbehave if they already exist

    I do know ‘Add From Server’ just reports “File not added” and does nothing else whenever the registration of a selected upload already exists in the targeted database, but I think your point there concerning what WordPress might or might not do when it discovers the thumbnails already exist might be a valid concern.

    wp code of the media library crashes/misbehave when you open the media library, and there are files on disk, never registered in its own database (because uploaded the first time, by another blog, that is registered in another database)

    Maybe I am wrong in believing “extras” are simply ignored.

    (of course, I will just go ahead, set up everything, see what happens and report…[after] asking and studying, 5 minutes at a time)

    I do the same. Just be certain complete backups all around is the final preparatory step!

    Thread Starter mfioretti

    (@mfioretti)

    This page, as I understand it:

    http://wordpress.stackexchange.com/questions/67840/where-does-the-media-library-live-in-the-database

    seems to confirm what I wrote before. If wp shows in media library what is written in wp_posts and wp_postmeta, it seems certain that if you upload an image in blog 1 (=write its path, data etc) in the wp_posts, wp_postmeta tables of database 1, when you open the media library of blog 2 it won’t display those images. Unless its own tables too have been somehow updated… Seems a job for wp-cli, if it is possible…

    when you open the media library of blog 2 it won’t display those images. Unless its own tables too have been somehow updated…

    Understood, and that is what ‘Add from Server’ could address, yet as subject to how WordPress might act when it discovers the thumbnails already exist and then also the later matter of caching you had mentioned.

    Hi guys, i’m looking for a solution for this exact problem!
    Any updates?
    Daniel

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Can different wp databases share the SAME UPLOADS FOLDER?’ is closed to new replies.