WordPress.org

Make WordPress Core

Opened 5 years ago

Closed 5 years ago

#37413 closed enhancement (invalid)

Use `get_site()` instead of global `$current_blog`

Reported by: flixos90 Owned by: flixos90
Milestone: Priority: normal
Severity: normal Version: 4.6
Component: Networks and Sites Keywords: needs-patch
Focuses: multisite Cc:

Description

get_site() falls back to the current site if no parameter is provided. That means we can use it anywhere we currently work with globals (or maybe even get_current_blog_id()).

Change History (2)

#1 @flixos90
5 years ago

  • Milestone changed from Future Release to 4.7
  • Owner set to flixos90
  • Status changed from new to assigned

#2 @flixos90
5 years ago

  • Milestone 4.7 deleted
  • Resolution set to invalid
  • Status changed from assigned to closed

I just searched through the WordPress codebase and actually wasn't able to find any occurrence of the $current_blog global where the code was not part of the global scope anyway. Therefore I would consider this an invalid ticket - when I opened it, I assumed there were cases where this change was necessary, so it's great that there aren't. :)

Although I mentioned this in the ticket description, I don't think we should (and even can) replace get_current_blog_id() occurrences. While it would be nice for more usage of current naming conventions in the code, get_current_blog_id() is easier to use than get_site()->id and, more importantly, also works outside of Multisite.

Note: See TracTickets for help on using tickets.