[wp-trac] [WordPress Trac] #40623: Investigate new file structure for Multisite functionality

WordPress Trac noreply at wordpress.org
Mon May 1 17:51:05 UTC 2017


#40623: Investigate new file structure for Multisite functionality
--------------------------------+-----------------------------
 Reporter:  flixos90            |      Owner:
     Type:  defect (bug)        |     Status:  new
 Priority:  normal              |  Milestone:  Awaiting Review
Component:  Networks and Sites  |    Version:
 Severity:  normal              |   Keywords:
  Focuses:  multisite           |
--------------------------------+-----------------------------
 Currently core multisite functionality resides in the following files:

 '''Loaded early:'''

 * `class-wp-site-query.php`
 * `class-wp-network-query.php`
 * `ms-blogs.php`

 '''Bootstrap File:'''

 * `ms-settings.php`

 '''Loaded by bootstrap file:'''

 * `class-wp-network.php`
 * `class-wp-site.php`
 * `ms-load.php`
 * `ms-default-constants.php`

 '''Loaded after WordPress Core stuff:'''

 * `ms-functions.php`
 * `ms-default-filters.php`
 * `ms-deprecated.php`

 This structure and loading order is problematic for several reasons.

 1. The functionality is not clearly separated. File names (particularly
 `ms-blogs.php` and `ms-functions.php` provide no idea (or confusion about)
 what they contain. For example `ms-blogs.php` contains read functionality
 for sites and networks plus a bit of updating site functions (the old
 `*_blog_details()` stuff), `ms-functions.php` contains functions for
 creating sites and users.
 2. Future improvements (such as #37923 and #25344) run into problems since
 they need to declare new functions in `ms-blogs.php` which require other
 functions that are declared in Core files that are loaded after it.
 3. While `ms-settings.php` is the multisite bootstrap file just as `wp-
 settings.php` loads the regular Core functionality, `ms-settings.php` is
 loaded before most parts of Core, which feels weird to me and may cause
 problems (see 2. above).

 I think we should find a way to improve this through a more clarifying
 file structure and loading order. Some ideas I have:
 * Introduce files `ms-site.php` and `ms-network.php` and move all basic
 API functions for that specific area into them (those files would be
 similar like `post.php` and `taxonomy.php` for example). `ms-site.php`
 should for example contain things like `get_site()`, `get_sites()`,
 related cache functions, functions such as those created in #40364,
 `*_site_meta()` functions (if #37923 makes it into Core); `ms-network.php`
 would contain `get_network()`, `get_networks()`, related cache functions,
 `*_network_meta()` functions (if #25344 makes it into Core) etc. I think
 we should only put "new" functions into those files (with "new" I mean
 more recent things that follow the current naming conventions in
 Multisite). We might also add an `ms-user.php` file.
 * Load all Multisite functionality after Core functionality. This would
 solve issues where Core functionality needed is not available in early-
 loaded files, and also that other Multisite functionality is not available
 (for example you shouldn't currently call `ms-functions.php` functions
 from `ms-blogs.php`. We have to be careful with BC, edge-cases and all the
 other things that might come up when changing loading order - so not sure
 whether this is possible, but it's something to think about.

 Let's think about it.

--
Ticket URL: <https://core.trac.wordpress.org/ticket/40623>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list