Make WordPress Core

Opened 12 years ago

Closed 11 years ago

#19030 closed enhancement (invalid)


Reported by: unsalkorkmaz's profile unsalkorkmaz Owned by:
Milestone: Priority: normal
Severity: normal Version: 3.0
Component: Multisite Keywords:
Focuses: Cc:


I am trying to sharding BLOGUPLOADDIR but couldnt success atm. This is default one:

define( 'BLOGUPLOADDIR', WP_CONTENT_DIR . "/blogs.dir/{$wpdb->blogid}/files/" );

I am trying to set it:

    $bloggroup = 'global';
    $bloggroup = 'bloggroup'.floor($wpdb->blogid/2000+1); // 1999->1, 2000->2
define( 'BLOGUPLOADDIR', WP_CONTENT_DIR . "/blogs.dir/{$bloggroup}/{$wpdb->blogid}/files/" );

So every 2000 blog, bloggroup will change.. I tried upload_dir filter but i need to define before it. I tried sunrise.php but $wpdb->blogid is not defined in there it seems. Whats proper way of this?

btw i think this need change:

$dir = apply_filters( 'wpmu_delete_blog_upload_dir', WP_CONTENT_DIR . "/blogs.dir/{$blog_id}/files/", $blog_id );

it wont delete uploads if i define BLOGUPLOADDIR right?

Change History (9)

#1 @unsalkorkmaz
12 years ago

even when i set wpmu_delete_blog_upload_dir with filter, system deleting files but not folders.

#2 @unsalkorkmaz
12 years ago

  • Version set to 3.3

#3 @nacin
12 years ago

  • Version changed from 3.3 to 3.0

I'm a bit confused by the examples. Would it make more sense to try the support forums?

#4 @unsalkorkmaz
12 years ago

Actually i can simplify my question:
How or where can i define BLOGUPLOADDIR with using $wpdb->blogid ?

Plugins are too late, wp-config file is too early for $wpdb->blogid, sunrise.php file dont have $wpdb->blogid if we dont use a hard solution like

#5 @nacin
12 years ago

  • Type changed from defect (bug) to enhancement

Sunrise doesn't have the $wpdb->blogid, but it does have the blog ID. Or rather, you'd use sunrise to calculate the blog ID.

It would be nice for a hook to fire after ms-settings.php but before ms_upload_constants() fires.

#6 @unsalkorkmaz
12 years ago

If i dont miss something, sunrise just have blog ID = 1 as defined in wp-config which is a wrong id for sub sites.. right?

#7 @nacin
12 years ago

sunrise.php is designed to replace ms-settings.php by calculating and setting $current_site and $current_blog.

#8 @wpmuguru
11 years ago

  • Keywords close added

Sharding of the blogs.dir directory was typically handled in sunrise.php as well.

sunrise.php could be used to do database lookups and define any of the MU/MS specific constants.

Given #19235, I'm rcommending we close this one. Since sharding involved moving files around anyway there isn't any advantage to continuing to use ms-files.php after the files are moved.

#9 @SergeyBiryukov
11 years ago

  • Keywords close removed
  • Milestone Awaiting Review deleted
  • Resolution set to invalid
  • Status changed from new to closed
Note: See TracTickets for help on using tickets.