[wp-trac] [WordPress Trac] #41684: Replace $wpdb->blogid with get_current_blog_id()

WordPress Trac noreply at wordpress.org
Tue Sep 12 04:48:38 UTC 2017


#41684: Replace $wpdb->blogid with get_current_blog_id()
-------------------------------------------------+-------------------------
 Reporter:  spacedmonkey                         |       Owner:  bnap00
     Type:  defect (bug)                         |      Status:  assigned
 Priority:  normal                               |   Milestone:  4.9
Component:  Networks and Sites                   |     Version:  3.1
 Severity:  normal                               |  Resolution:
 Keywords:  good-first-bug needs-unit-tests      |     Focuses:  multisite
  has-patch                                      |
-------------------------------------------------+-------------------------
Changes (by jeremyfelt):

 * owner:   => bnap00
 * status:  new => assigned
 * milestone:  Future Release => 4.9


Comment:

 Thanks for your work on this, @bnap00.

 In cases where value is used more than once in a function, and where extra
 clarity is not needed, I think it's safe to store locally for reuse
 (`$site_id = get_current_blog_id()`) instead of calling the function
 multiple times. The best (maybe the only) example is probably `src/wp-
 admin/includes/upgrade.php`.

 And, less important, `return $blogs[get_current_blog_id()]; ` can be
 updated to `return $blogs[ get_current_blog_id() ];` for coding standards.

--
Ticket URL: <https://core.trac.wordpress.org/ticket/41684#comment:7>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list