Much of the bootstrap code for Multisite in ms-settings.php has been refactored in #27003 with the intent to improve how we handle the detection of domains and paths for sites and networks in core. Several other smaller enhancements and bugs have been completed in this and in other tickets.
How networks and sites are found
In the most common multisite scenario, the network finding process is the same. The constants
PATH_CURRENT_SITE in your wp-config.php define the network to be loaded by WordPress. In the large majority of installations there is only one network.
The default process for finding the requested site now goes through a new function,
get_site_by_path(). See the new functions section below for more details.
If you use a sunrise file—likely through a domain mapping or multi-network plugin—and the
$current_blog globals are configured there through a custom network and site detection process, the finding portions of ms-settings.php will continue to be skipped entirely. Nothing changes.
In some (very) rare scenarios, multiple networks may be configured in WordPress without a sunrise file. It is here where both the site and network finding process has been altered to use new functions rather than the stream of bootstrap code.
There are two deprecated functions that may appear in your sunrise or in plugins to watch out for. Both of these were intended for private use by core, but came in handy as helpers to hack around various bits and pieces of the load process.
wpmu_current_site() is deprecated. It was previously used to find the network and site information for a request. All functionality has been removed from this in favor of replacement functions. In its current form, it returns the $current_site global.
get_current_site_name() is deprecated. It was previously used to set the site_name property on a given $current_site object. In its current form, it returns the passed $current_site object. This will likely not break anything, but any code relying on retrieving a site name using this function should be modified to use get_current_site() instead.
Three new functions have been added to ms-load.php in 3.9 development. All of these have the focus of making sites and networks easier to find. These are meant to be public replacements for the previously private and somewhat inaccessible logic that existed in the bootstrap.
wp_get_network() retrieves an object containing the network’s information from the database when passed a network ID.
get_site_by_path() retrieves a site object when passed a domain and path. Two new filters are available here.
get_network_by_path() retrieves a network object when passed a domain and path. Two new filters are available here as well.
Inside the new site and network finding functions are a few filters that go a long way in providing for a less hacky sunrise.php file in the future. These can be used to shape the multisite bootstrap process without entirely replacing the logic.
site_by_path_segments_count fires in
get_site_by_path() and sets the number of possible path segments a site may have when we’re searching for it.
pre_get_site_by_path fires in
get_site_by_path() and allows you to short-circuit core’s default logic for finding a site.
network_by_path_segments_count fires in
get_network_by_path() and sets the number of possible path segments a network may have when we’re searching for it.
pre_get_network_by_path fires in
get_network_by_path() and allows you to short-circuit core’s default logic for finding a network.
It’s exciting to see some of the progress we’re making around multisite. We’d like to see what can be solved or broken with the new filters. More future improvements will be made around this and we want to make sure the base is right.
Also take a look at the multisite focused tickets closed as fixed for 3.9. There are several other improvements and bug fixes that are worth taking a look at.
See #25348 for autocompleting users when adding a new site. See #20601 for proper 404 handling of non member author archives. See #24178 for past confusion with a plugin that is activated on the network and locally.