[wp-trac] [WordPress Trac] #31556: `$wpdb` global object should be retrieved via a helper function to help prevent global stomping

WordPress Trac noreply at wordpress.org
Fri May 1 14:42:03 UTC 2015


#31556: `$wpdb` global object should be retrieved via a helper function to help
prevent global stomping
-----------------------------------+------------------------------
 Reporter:  jtsternberg            |       Owner:
     Type:  enhancement            |      Status:  new
 Priority:  normal                 |   Milestone:  Awaiting Review
Component:  Query                  |     Version:  4.2
 Severity:  normal                 |  Resolution:
 Keywords:  has-patch 2nd-opinion  |     Focuses:
-----------------------------------+------------------------------

Comment (by jdgrimes):

 Replying to [comment:8 jtsternberg]:
 > Along those lines, I'm curious if there are any performance implications
 to `global $wpdb; return $wpdb;` vs `return $GLOBALS['wpdb'];`.

 `return $GLOBALS['wpdb'];` is about 15% faster, based on a similar
 benchmark I ran a while back.

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


More information about the wp-trac mailing list