Changeset 6346
- Timestamp:
- 11/27/2007 10:14:53 PM (17 years ago)
- Location:
- trunk
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-admin/includes/user.php
r6303 r6346 273 273 wp_cache_delete($id, 'users'); 274 274 wp_cache_delete($user->user_login, 'userlogins'); 275 wp_cache_delete($user->user_email, 'useremail'); 275 276 276 277 return true; -
trunk/wp-includes/pluggable.php
r6330 r6346 61 61 function get_userdata( $user_id ) { 62 62 global $wpdb; 63 63 64 $user_id = abs(intval($user_id)); 64 65 if ( $user_id == 0 ) … … 67 68 $user = wp_cache_get($user_id, 'users'); 68 69 69 if ( $user ) 70 if ( '0' === $user ) 71 return false; 72 else if ( $user ) 70 73 return $user; 71 74 72 if ( !$user = $wpdb->get_row($wpdb->prepare("SELECT * FROM $wpdb->users WHERE ID = %d LIMIT 1", $user_id)) ) 73 return false; 74 75 $wpdb->hide_errors(); 76 $metavalues = $wpdb->get_results($wpdb->prepare("SELECT meta_key, meta_value FROM $wpdb->usermeta WHERE user_id = %d", $user_id)); 77 $wpdb->show_errors(); 78 79 if ($metavalues) { 80 foreach ( $metavalues as $meta ) { 81 $value = maybe_unserialize($meta->meta_value); 82 $user->{$meta->meta_key} = $value; 83 84 // We need to set user_level from meta, not row 85 if ( $wpdb->prefix . 'user_level' == $meta->meta_key ) 86 $user->user_level = $meta->meta_value; 87 } // end foreach 88 } //end if 89 90 // For backwards compat. 91 if ( isset($user->first_name) ) 92 $user->user_firstname = $user->first_name; 93 if ( isset($user->last_name) ) 94 $user->user_lastname = $user->last_name; 95 if ( isset($user->description) ) 96 $user->user_description = $user->description; 97 98 wp_cache_add($user_id, $user, 'users'); 99 wp_cache_add($user->user_login, $user_id, 'userlogins'); 75 if ( !$user = $wpdb->get_row($wpdb->prepare("SELECT * FROM $wpdb->users WHERE ID = %d LIMIT 1", $user_id)) ) { 76 wp_cache_add($user_id, 0, 'users'); 77 return false; 78 } 79 80 _fill_user($user); 81 100 82 return $user; 101 83 } … … 117 99 118 100 $user_id = wp_cache_get($user_login, 'userlogins'); 119 $userdata = wp_cache_get($user_id, 'users'); 120 121 if ( $userdata ) 122 return $userdata; 123 124 if ( !$user_ID = $wpdb->get_var($wpdb->prepare("SELECT ID FROM $wpdb->users WHERE user_login = %s", $user_login)) ) 125 return false; 126 127 $user = get_userdata($user_ID); 101 if ( '0' === $user_id ) 102 return false; 103 104 $user = false; 105 if ( false !== $user_id ) 106 $user = wp_cache_get($user_id, 'users'); 107 108 if ( false !== $user ) 109 return $user; 110 111 if ( !$user = $wpdb->get_row($wpdb->prepare("SELECT * FROM $wpdb->users WHERE user_login = %s", $user_login)) ) { 112 wp_cache_add($user_login, 0, 'userlogins'); 113 return false; 114 } 115 116 _fill_user($user); 117 118 return $user; 119 } 120 endif; 121 122 if ( !function_exists('get_user_by_email') ) : 123 function get_user_by_email($email) { 124 global $wpdb; 125 126 $user_id = wp_cache_get($email, 'useremail'); 127 128 if ( '0' === $user_id ) 129 return false; 130 131 $user = false; 132 if ( false !== $user_id ) 133 $user = wp_cache_get($user_id, 'users'); 134 135 if ( false !== $user ) 136 return $user; 137 138 if ( !$user = $wpdb->get_row($wpdb->prepare("SELECT * FROM $wpdb->users WHERE user_email = %s", $email)) ) { 139 wp_cache_add($email, 0, 'useremail'); 140 return false; 141 } 142 143 _fill_user($user); 144 128 145 return $user; 129 146 } -
trunk/wp-includes/registration.php
r6302 r6346 7 7 */ 8 8 function username_exists( $username ) { 9 if ( $user = get_userdatabylogin( sanitize_user( $username )) ) {9 if ( $user = get_userdatabylogin( $username ) ) { 10 10 return $user->ID; 11 11 } else { … … 21 21 */ 22 22 function email_exists( $email ) { 23 global $wpdb; 24 return $wpdb->get_var( $wpdb->prepare( "SELECT ID FROM $wpdb->users WHERE user_email = %s", $email) ); 23 if ( $user = get_user_by_email($email) ) 24 return $user->ID; 25 26 return false; 25 27 } 26 28 -
trunk/wp-includes/user.php
r6260 r6346 79 79 $user = get_userdata($user_id); 80 80 wp_cache_delete($user_id, 'users'); 81 wp_cache_delete($user->user_login, 'userlogins');82 81 83 82 return true; … … 143 142 $user = get_userdata($user_id); 144 143 wp_cache_delete($user_id, 'users'); 145 wp_cache_delete($user->user_login, 'userlogins');146 144 147 145 return true; … … 239 237 } 240 238 239 function _fill_user( &$user ) { 240 global $wpdb; 241 242 $wpdb->hide_errors(); 243 $metavalues = $wpdb->get_results($wpdb->prepare("SELECT meta_key, meta_value FROM $wpdb->usermeta WHERE user_id = %d", $user->ID)); 244 $wpdb->show_errors(); 245 246 if ( $metavalues ) { 247 foreach ( $metavalues as $meta ) { 248 $value = maybe_unserialize($meta->meta_value); 249 $user->{$meta->meta_key} = $value; 250 } 251 } 252 253 $level = $wpdb->prefix . 'user_level'; 254 if ( isset( $user->{$level} ) ) 255 $user->user_level = $user->{$level}; 256 257 // For backwards compat. 258 if ( isset($user->first_name) ) 259 $user->user_firstname = $user->first_name; 260 if ( isset($user->last_name) ) 261 $user->user_lastname = $user->last_name; 262 if ( isset($user->description) ) 263 $user->user_description = $user->description; 264 265 wp_cache_add($user->ID, $user, 'users'); 266 wp_cache_add($user->user_login, $user->ID, 'userlogins'); 267 wp_cache_add($user->user_email, $user->ID, 'useremail'); 268 } 269 241 270 ?>
Note: See TracChangeset
for help on using the changeset viewer.