[wp-trac] [WordPress Trac] #25158: Use get_current_site() instead of the $current_site global when possible

WordPress Trac noreply at wordpress.org
Tue Aug 27 16:52:58 UTC 2013


#25158: Use get_current_site() instead of the $current_site global when possible
--------------------------+-----------------------------
 Reporter:  jeremyfelt    |      Owner:
     Type:  defect (bug)  |     Status:  new
 Priority:  normal        |  Milestone:  Awaiting Review
Component:  Multisite     |    Version:
 Severity:  normal        |   Keywords:  has-patch
--------------------------+-----------------------------
 Via prod from Nacin, this does seem like
 [http://irclogs.wordpress.org/chanlog.php?channel=wordpress-
 dev&day=2013-08-27&sort=asc#m675518 a good cleanup opportunity]

 Patch removes almost all uses of the global `$current_site` and replaces
 with `get_current_site()`.

 Notes:
 1. `is_main_site()` doesn't necessarily have access to
 `get_current_site()` when first used and therefore requires the global
 `$current_site`.
 2. `populate_network()` sets parts of the `$current_site` global when
 transitioning from single site to multisite and therefore needs access.
 3. `get_current_site()` obviously needs access to the global
 4. `get_current_site_name()` uses a local `$current_site`object that is
 passed to it
 5. `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`.
 6. `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. :)

--
Ticket URL: <http://core.trac.wordpress.org/ticket/25158>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software


More information about the wp-trac mailing list