Use get_current_site() instead of the $current_site global when possible
|Reported by:||jeremyfelt||Owned by:||SergeyBiryukov|
Via prod from Nacin, this does seem like a good cleanup opportunity
Patch removes almost all uses of the global $current_site and replaces with get_current_site().
- is_main_site() doesn't necessarily have access to get_current_site() when first used and therefore requires the global $current_site.
- populate_network() sets parts of the $current_site global when transitioning from single site to multisite and therefore needs access.
- get_current_site() obviously needs access to the global
- get_current_site_name() uses a local $current_siteobject that is passed to it
- wpmu_current_site() is responsible for setting up the $current_site global and therefore appears to need access. However, I'm not entirely convinced it really is required as wpmu_current_site() is only called once by core and that is to set the global in ms-settings.php.
- ms-settings.php is where $current_site hits the global scope, so it stays.
No new failures arise in tests for both single and multisite mode. There were a couple places where I made small code formatting tweaks, though I tried to restrain. :)
Change History (23)
comment:8 SergeyBiryukov — 6 months ago
- Keywords commit added
- Milestone changed from Awaiting Review to 3.7
comment:13 SergeyBiryukov — 4 months ago
- Resolution set to fixed
- Status changed from assigned to closed
comment:15 SergeyBiryukov — 4 months ago
- Resolution fixed deleted
- Status changed from closed to reopened