#1174 closed enhancement (fixed)
wasted mysql query for logged in users can be eliminated
| Reported by: |
|
Owned by: | |
|---|---|---|---|
| Priority: | normal | Milestone: | 1.0.3 |
| Component: | Back-end | Version: | 0.9.0.6 |
| Severity: | normal | Keywords: | |
| Cc: |
Description
This is for 0.9 branch only, unfortunately this cannot be taken advantage of for 1.0 because the process is buried in BackPress (but the concept could still be applied with a bit extra work).
A query is wasted for every page load for every logged in user because while the row is located for the user by name in function get_user_by_name based on what's in the cookie - the user is not loaded at that time. Instead the ID is passed to yet another query to load the user.
This can be easily fixed at the bottom of
function wp_validate_auth_cookie($cookie = '') {
change from:
$user = bb_get_user_by_name($username); if ( ! $user ) return false; return $user->ID;
to:
$username = sanitize_user( $username, true );
global $bbdb;
if ( $user = $bbdb->get_row( $bbdb->prepare( "SELECT * FROM $bbdb->users WHERE user_login = %s", $username ) ) ) {
bb_append_meta( $user, 'user' );
}
if ( empty($user->ID) ) {return false;}
return $user->ID;
Plugin attached to provide the entire functionality.
Attachments (1)
Note: See
TracTickets for help on using
tickets.
(In [2346]) branches 0.9: Remove a query from each pageload. Props _ck_. Fixes #1174.