[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:23:48 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:6 jdgrimes]:
> I realize performance may not be a big concern here, but FWIW, a
function call takes over twice the amount of time as declaring a global.
We might want to consider just replacing `global $wpdb` with `$wpdb =
wpdb()`. Less churn, no global, more performant.
To clarify, what I'm saying is that replacing every single use of the
`$wpdb` variable with a call to a function will reduce performance.
Calling the function just once, and using the variable as we already do
will be more performant and won't require the code churn.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/31556#comment:7>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list