Make WordPress Core

Ticket #15458: lazy-load.3.diff

File lazy-load.3.diff, 23.7 KB (added by scribu, 14 years ago)
  • wp-admin/includes/class-wp-users-list-table.php

    diff --git a/wp-admin/includes/class-wp-users-list-table.php b/wp-admin/includes/class-wp-users-list-table.php
    index de22748..13bdeb4 100644
    a b class WP_Users_List_Table extends WP_List_Table { 
    219219
    220220                if ( !( is_object( $user_object ) && is_a( $user_object, 'WP_User' ) ) )
    221221                        $user_object = new WP_User( (int) $user_object );
    222                 $user_object = sanitize_user_object( $user_object, 'display' );
     222                $user_object->filter = 'display';
    223223                $email = $user_object->user_email;
    224224
    225225                if ( $this->is_site_users )
  • wp-admin/includes/user.php

    diff --git a/wp-admin/includes/user.php b/wp-admin/includes/user.php
    index 758c065..5d513b9 100644
    a b function get_editable_roles() { 
    226226function get_user_to_edit( $user_id ) {
    227227        $user = new WP_User( $user_id );
    228228
    229         $user_contactmethods = _wp_get_user_contactmethods( $user );
    230         foreach ($user_contactmethods as $method => $name) {
    231                 if ( empty( $user->{$method} ) )
    232                         $user->{$method} = '';
    233         }
    234 
    235         if ( empty($user->description) )
    236                 $user->description = '';
    237 
    238         $user = sanitize_user_object($user, 'edit');
     229        $user->filter = 'edit';
    239230
    240231        return $user;
    241232}
  • wp-includes/capabilities.php

    diff --git a/wp-includes/capabilities.php b/wp-includes/capabilities.php
    index ae2dc2a..a8e7f33 100644
    a b class WP_User { 
    420420         */
    421421        var $filter = null;
    422422
     423        private static $back_compat_keys = array(
     424                'user_firstname' => 'first_name',
     425                'user_lastname' => 'last_name',
     426                'user_description' => 'description'
     427        );
     428
    423429        /**
    424          * Constructor - Sets up the object properties.
     430         * Constructor
    425431         *
    426          * Retrieves the userdata and then assigns all of the data keys to direct
    427          * properties of the object. Calls {@link WP_User::_init_caps()} after
    428          * setting up the object's user data properties.
     432         * Retrieves the userdata and passes it to {@link WP_User::init()}.
    429433         *
    430434         * @since 2.0.0
    431435         * @access public
    432436         *
    433          * @param int|string $id User's ID or username
    434          * @param int $name Optional. User's username
     437         * @param int|string $id User's ID
     438         * @param string $name Optional. User's username
    435439         * @param int $blog_id Optional Blog ID, defaults to current blog.
    436440         * @return WP_User
    437441         */
    438         function __construct( $id, $name = '', $blog_id = '' ) {
    439                 if ( empty( $id ) && empty( $name ) )
    440                         return;
    441 
     442        function __construct( $id = 0, $name = '', $blog_id = '' ) {
    442443                if ( ! is_numeric( $id ) ) {
    443444                        $name = $id;
    444445                        $id = 0;
    445446                }
    446447
    447                 if ( ! empty( $id ) )
    448                         $this->data = get_userdata( $id );
     448                if ( $id )
     449                        $data = self::get_data_by( 'id', $id );
    449450                else
    450                         $this->data = get_user_by('login', $name );
     451                        $data = self::get_data_by( 'login', $name );
    451452
    452                 if ( empty( $this->data->ID ) )
    453                         return;
     453                if ( $data )
     454                        $this->init( $data, $blog_id );
     455        }
     456
     457        /**
     458         * Sets up object properties, including capabilities.
     459         *
     460         * @param object $data User DB row object
     461         * @param int $blog_id Optional. The blog id to initialize for
     462         */
     463        function init( $data, $blog_id = '' ) {
     464                $this->data = $data;
     465                $this->ID = (int) $data->ID;
    454466
    455                 $this->ID = $this->data->ID;
    456467                $this->for_blog( $blog_id );
    457468        }
    458469
    459470        /**
     471         * Return only the main user fields
     472         *
     473         * @since 3.3.0
     474         *
     475         * @param string $field The field to query against: 'id', 'slug', 'email' or 'login'
     476         * @param string|int $value The field value
     477         */
     478        static function get_data_by( $field, $value ) {
     479                global $wpdb;
     480
     481                if ( 'id' == $field )
     482                        $value = absint( $value );
     483                else
     484                        $value = trim( $value );
     485
     486                if ( !$value )
     487                        return false;
     488
     489                switch ( $field ) {
     490                        case 'id':
     491                                $user_id = $value;
     492                                $db_field = 'ID';
     493                                break;
     494                        case 'slug':
     495                                $user_id = wp_cache_get($value, 'userslugs');
     496                                $db_field = 'user_nicename';
     497                                break;
     498                        case 'email':
     499                                $user_id = wp_cache_get($value, 'useremail');
     500                                $db_field = 'user_email';
     501                                break;
     502                        case 'login':
     503                                $value = sanitize_user( $value );
     504                                $user_id = wp_cache_get($value, 'userlogins');
     505                                $db_field = 'user_login';
     506                                break;
     507                        default:
     508                                return false;
     509                }
     510
     511                if ( false !== $user_id ) {
     512                        if ( $user = wp_cache_get( $user_id, 'users' ) )
     513                                return $user;
     514                }
     515
     516                if ( !$user = $wpdb->get_row( $wpdb->prepare(
     517                        "SELECT * FROM $wpdb->users WHERE $db_field = %s", $value
     518                ) ) )
     519                        return false;
     520
     521                update_user_caches( $user );
     522
     523                return $user;
     524        }
     525
     526        /**
    460527         * Magic method for checking the existance of a certain custom field
    461528         *
    462529         * @since 3.3.0
    class WP_User { 
    480547                        return $this->ID;
    481548                }
    482549
    483                 return $this->data->$key;
     550                if ( isset( $this->data->$key ) ) {
     551                        $value = $this->data->$key;
     552                } else {
     553                        if ( isset( self::$back_compat_keys[ $key ] ) )
     554                                $key = self::$back_compat_keys[ $key ];
     555                        $value = get_user_meta( $this->ID, $key, true );
     556                }
     557
     558                if ( $this->filter ) {
     559                        $value = sanitize_user_field( $key, $value, $this->ID, $this->filter );
     560                }
     561
     562                return $value;
    484563        }
    485564
    486565        /**
    class WP_User { 
    519598                else
    520599                        $this->cap_key = $cap_key;
    521600
    522                 $this->caps = &$this->data->{$this->cap_key};
     601                $this->caps = get_user_meta( $this->ID, $this->cap_key, true );
     602
    523603                if ( ! is_array( $this->caps ) )
    524604                        $this->caps = array();
    525605
    class WP_User { 
    662742         */
    663743        function update_user_level_from_caps() {
    664744                global $wpdb;
    665                 $this->user_level = array_reduce( array_keys( $this->allcaps ), array( &$this, 'level_reduction' ), 0 );
     745                $this->user_level = array_reduce( array_keys( $this->allcaps ), array( $this, 'level_reduction' ), 0 );
    666746                update_user_meta( $this->ID, $wpdb->prefix . 'user_level', $this->user_level );
    667747        }
    668748
    function current_user_can( $capability ) { 
    10661146        $args = array_slice( func_get_args(), 1 );
    10671147        $args = array_merge( array( $capability ), $args );
    10681148
    1069         return call_user_func_array( array( &$current_user, 'has_cap' ), $args );
     1149        return call_user_func_array( array( $current_user, 'has_cap' ), $args );
    10701150}
    10711151
    10721152/**
  • wp-includes/deprecated.php

    diff --git a/wp-includes/deprecated.php b/wp-includes/deprecated.php
    index 8313a3f..df1f03e 100644
    a b function wp_timezone_supported() { 
    26272627 */
    26282628function wp_default_editor() {
    26292629        _deprecated_function( __FUNCTION__, '3.3' );
    2630        
     2630
    26312631        global $wp_editor;
    26322632        if ( !is_a($wp_editor, 'WP_Editor') ) {
    26332633                require_once( ABSPATH . WPINC . '/class-wp-editor.php' );
    26342634                $wp_editor = new WP_Editor;
    26352635        }
    2636        
     2636
    26372637        return $wp_editor->wp_default_editor();
    26382638}
    26392639
    function wp_default_editor() { 
    26412641 * Display editor: TinyMCE, HTML, or both.
    26422642 *
    26432643 * @since 2.1.0
    2644  * @deprecated 3.3 
     2644 * @deprecated 3.3
    26452645 *
    26462646 * @param string $content Textarea content.
    26472647 * @param string $id Optional, default is 'content'. HTML ID attribute value.
    function wp_default_editor() { 
    26502650 * @param int $tab_index Optional, not used
    26512651 */
    26522652function the_editor($content, $id = 'content', $prev_id = 'title', $media_buttons = true, $tab_index = 2, $extended = true) {
    2653        
     2653
    26542654        wp_editor( $content, $id, array( 'media_buttons' => $media_buttons ) );
    26552655        return;
    26562656}
    26572657
     2658/**
     2659 * Perform the query to get the $metavalues array(s) needed by _fill_user and _fill_many_users
     2660 *
     2661 * @since 3.0.0
     2662 * @param array $ids User ID numbers list.
     2663 * @return array of arrays. The array is indexed by user_id, containing $metavalues object arrays.
     2664 */
     2665function get_user_metavalues($ids) {
     2666        _deprecated_function( __FUNCTION__, '3.3' );
     2667
     2668        $objects = array();
     2669
     2670        $ids = array_map('intval', $ids);
     2671        foreach ( $ids as $id )
     2672                $objects[$id] = array();
     2673
     2674        $metas = update_meta_cache('user', $ids);
     2675
     2676        foreach ( $metas as $id => $meta ) {
     2677                foreach ( $meta as $key => $metavalues ) {
     2678                        foreach ( $metavalues as $value ) {
     2679                                $objects[$id][] = (object)array( 'user_id' => $id, 'meta_key' => $key, 'meta_value' => $value);
     2680                        }
     2681                }
     2682        }
     2683
     2684        return $objects;
     2685}
     2686
     2687/**
     2688 * Sanitize every user field.
     2689 *
     2690 * If the context is 'raw', then the user object or array will get minimal santization of the int fields.
     2691 *
     2692 * @since 2.3.0
     2693 * @deprecated 3.3.0
     2694 * @uses sanitize_user_field() Used to sanitize the fields.
     2695 *
     2696 * @param object|array $user The User Object or Array
     2697 * @param string $context Optional, default is 'display'. How to sanitize user fields.
     2698 * @return object|array The now sanitized User Object or Array (will be the same type as $user)
     2699 */
     2700function sanitize_user_object($user, $context = 'display') {
     2701        _deprecated_function( __FUNCTION__, '3.3' );
     2702
     2703        if ( is_object($user) ) {
     2704                if ( !isset($user->ID) )
     2705                        $user->ID = 0;
     2706                if ( !is_a( $user, 'WP_User' ) ) {
     2707                        $vars = get_object_vars($user);
     2708                        foreach ( array_keys($vars) as $field ) {
     2709                                if ( is_string($user->$field) || is_numeric($user->$field) )
     2710                                        $user->$field = sanitize_user_field($field, $user->$field, $user->ID, $context);
     2711                        }
     2712                }
     2713                $user->filter = $context;
     2714        } else {
     2715                if ( !isset($user['ID']) )
     2716                        $user['ID'] = 0;
     2717                foreach ( array_keys($user) as $field )
     2718                        $user[$field] = sanitize_user_field($field, $user[$field], $user['ID'], $context);
     2719                $user['filter'] = $context;
     2720        }
     2721
     2722        return $user;
     2723}
  • wp-includes/meta.php

    diff --git a/wp-includes/meta.php b/wp-includes/meta.php
    index 5031ba7..83e916f 100644
    a b function add_metadata($meta_type, $object_id, $meta_key, $meta_value, $unique = 
    7373        $mid = (int) $wpdb->insert_id;
    7474
    7575        wp_cache_delete($object_id, $meta_type . '_meta');
    76         // users cache stores usermeta that must be cleared.
    77         if ( 'user' == $meta_type )
    78                 clean_user_cache($object_id);
    7976
    8077        do_action( "added_{$meta_type}_meta", $mid, $object_id, $meta_key, $_meta_value );
    8178
    function update_metadata($meta_type, $object_id, $meta_key, $meta_value, $prev_v 
    149146        }
    150147
    151148        do_action( "update_{$meta_type}_meta", $meta_id, $object_id, $meta_key, $_meta_value );
    152        
     149
    153150        if ( 'post' == $meta_type )
    154                 do_action( 'update_postmeta', $meta_id, $object_id, $meta_key, $meta_value );   
     151                do_action( 'update_postmeta', $meta_id, $object_id, $meta_key, $meta_value );
    155152
    156153        $wpdb->update( $table, $data, $where );
    157154
    158155        wp_cache_delete($object_id, $meta_type . '_meta');
    159         // users cache stores usermeta that must be cleared.
    160         if ( 'user' == $meta_type )
    161                 clean_user_cache($object_id);
    162156
    163157        do_action( "updated_{$meta_type}_meta", $meta_id, $object_id, $meta_key, $_meta_value );
    164        
     158
    165159        if ( 'post' == $meta_type )
    166                 do_action( 'updated_postmeta', $meta_id, $object_id, $meta_key, $meta_value );         
     160                do_action( 'updated_postmeta', $meta_id, $object_id, $meta_key, $meta_value );
    167161
    168162        return true;
    169163}
    function delete_metadata($meta_type, $object_id, $meta_key, $meta_value = '', $d 
    210204
    211205        $_meta_value = $meta_value;
    212206        $meta_value = maybe_serialize( $meta_value );
    213                
     207
    214208        $query = $wpdb->prepare( "SELECT $id_column FROM $table WHERE meta_key = %s", $meta_key );
    215209
    216210        if ( !$delete_all )
    function delete_metadata($meta_type, $object_id, $meta_key, $meta_value = '', $d 
    227221                $object_ids = $wpdb->get_col( $wpdb->prepare( "SELECT $type_column FROM $table WHERE meta_key = %s", $meta_key ) );
    228222
    229223        do_action( "delete_{$meta_type}_meta", $meta_ids, $object_id, $meta_key, $_meta_value );
    230        
     224
    231225        if ( 'post' == $meta_type )
    232226                do_action( 'delete_postmeta', $meta_ids );
    233227
    function delete_metadata($meta_type, $object_id, $meta_key, $meta_value = '', $d 
    246240                wp_cache_delete($object_id, $meta_type . '_meta');
    247241        }
    248242
    249         // users cache stores usermeta that must be cleared.
    250         if ( 'user' == $meta_type )
    251                 clean_user_cache($object_id);
    252 
    253243        do_action( "deleted_{$meta_type}_meta", $meta_ids, $object_id, $meta_key, $_meta_value );
    254        
     244
    255245        if ( 'post' == $meta_type )
    256246                do_action( 'deleted_postmeta', $meta_ids );
    257247
    function update_metadata_by_mid( $meta_type, $meta_id, $meta_value, $meta_key = 
    406396
    407397                if ( 'post' == $meta_type )
    408398                        do_action( 'update_postmeta', $meta_id, $object_id, $meta_key, $meta_value );
    409                
     399
    410400                // Run the update query, all fields in $data are %s, $where is a %d.
    411401                $result = (bool) $wpdb->update( $table, $data, $where, '%s', '%d' );
    412402
    413403                // Clear the caches.
    414404                wp_cache_delete($object_id, $meta_type . '_meta');
    415                
    416                 // Users cache stores usermeta that must be cleared.
    417                 if ( 'user' == $meta_type )
    418                         clean_user_cache($object_id);
    419405
    420406                do_action( "updated_{$meta_type}_meta", $meta_id, $object_id, $meta_key, $_meta_value );
    421407
    function update_metadata_by_mid( $meta_type, $meta_id, $meta_value, $meta_key = 
    424410
    425411                return $result;
    426412        }
    427        
     413
    428414        // And if the meta was not found.
    429415        return false;
    430416}
    function update_metadata_by_mid( $meta_type, $meta_id, $meta_value, $meta_key = 
    443429 */
    444430function delete_metadata_by_mid( $meta_type, $meta_id ) {
    445431        global $wpdb;
    446        
     432
    447433        // Make sure everything is valid.
    448434        if ( ! $meta_type )
    449435                return false;
    function delete_metadata_by_mid( $meta_type, $meta_id ) { 
    453439
    454440        if ( ! $table = _get_meta_table( $meta_type ) )
    455441                return false;
    456        
     442
    457443        // object and id columns
    458444        $column = esc_sql($meta_type . '_id');
    459445        $id_column = 'user' == $meta_type ? 'umeta_id' : 'meta_id';
    function delete_metadata_by_mid( $meta_type, $meta_id ) { 
    473459                // Clear the caches.
    474460                wp_cache_delete($object_id, $meta_type . '_meta');
    475461
    476                 // Users cache stores usermeta that must be cleared.
    477                 if ( 'user' == $meta_type )
    478                         clean_user_cache($object_id);
    479 
    480462                do_action( "deleted_{$meta_type}_meta", (array) $meta_id, $object_id, $meta->meta_key, $meta->meta_value );
    481463
    482464                if ( 'post' == $meta_type )
    function delete_metadata_by_mid( $meta_type, $meta_id ) { 
    485467                return $result;
    486468
    487469        }
    488        
     470
    489471        // Meta id was not found.
    490472        return false;
    491473}
    function sanitize_meta( $meta_key, $meta_value, $meta_type ) { 
    818800
    819801/**
    820802 * Register meta key
    821  * 
     803 *
    822804 * @since 3.3.0
    823805 *
    824806 * @param string $meta_type Type of meta
  • wp-includes/pluggable.php

    diff --git a/wp-includes/pluggable.php b/wp-includes/pluggable.php
    index fab5d41..9c5ad1d 100644
    a b if ( !function_exists('get_userdata') ) : 
    9898 * @since 0.71
    9999 *
    100100 * @param int $user_id User ID
    101  * @return bool|object False on failure, User DB row object
     101 * @return bool|object False on failure, WP_User object on success
    102102 */
    103103function get_userdata( $user_id ) {
    104         global $wpdb;
    105 
    106         if ( ! is_numeric( $user_id ) )
    107                 return false;
    108 
    109         $user_id = absint( $user_id );
    110         if ( ! $user_id )
    111                 return false;
    112 
    113         $user = wp_cache_get( $user_id, 'users' );
     104        return get_user_by( 'id', $user_id );
     105}
     106endif;
    114107
    115         if ( $user )
    116                 return $user;
     108if ( !function_exists('get_user_by') ) :
     109/**
     110 * Retrieve user info by a given field
     111 *
     112 * @since 2.8.0
     113 *
     114 * @param string $field The field to retrieve the user with.  id | slug | email | login
     115 * @param int|string $value A value for $field.  A user ID, slug, email address, or login name.
     116 * @return bool|object False on failure, WP_User object on success
     117 */
     118function get_user_by( $field, $value ) {
     119        $userdata = WP_User::get_data_by( $field, $value );
    117120
    118         if ( ! $user = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM $wpdb->users WHERE ID = %d LIMIT 1", $user_id ) ) )
     121        if ( !$userdata )
    119122                return false;
    120123
    121         _fill_user( $user );
     124        $user = new WP_User;
     125        $user->init( $userdata );
    122126
    123127        return $user;
    124128}
    if ( !function_exists('cache_users') ) : 
    130134 *
    131135 * @since 3.0.0
    132136 *
    133  * @param array $users User ID numbers list
     137 * @param array $user_ids User ID numbers list
    134138 */
    135 function cache_users( $users ) {
     139function cache_users( $user_ids ) {
    136140        global $wpdb;
    137141
    138142        $clean = array();
    139         foreach($users as $id) {
     143        foreach ( $user_ids as $id ) {
    140144                $id = (int) $id;
    141                 if (wp_cache_get($id, 'users')) {
    142                         // seems to be cached already
    143                 } else {
     145                if ( !wp_cache_get( $id, 'users' ) ) {
    144146                        $clean[] = $id;
    145147                }
    146148        }
    147149
    148         if ( 0 == count($clean) )
     150        if ( empty( $clean ) )
    149151                return;
    150152
    151         $list = implode(',', $clean);
     153        $list = implode( ',', $clean );
    152154
    153         $results = $wpdb->get_results("SELECT * FROM $wpdb->users WHERE ID IN ($list)");
     155        $users = $wpdb->get_results( "SELECT * FROM $wpdb->users WHERE ID IN ($list)" );
    154156
    155         _fill_many_users($results);
    156 }
    157 endif;
    158 
    159 if ( !function_exists('get_user_by') ) :
    160 /**
    161  * Retrieve user info by a given field
    162  *
    163  * @since 2.8.0
    164  *
    165  * @param string $field The field to retrieve the user with.  id | slug | email | login
    166  * @param int|string $value A value for $field.  A user ID, slug, email address, or login name.
    167  * @return bool|object False on failure, User DB row object
    168  */
    169 function get_user_by($field, $value) {
    170         global $wpdb;
    171 
    172         switch ($field) {
    173                 case 'id':
    174                         return get_userdata($value);
    175                         break;
    176                 case 'slug':
    177                         $user_id = wp_cache_get($value, 'userslugs');
    178                         $field = 'user_nicename';
    179                         break;
    180                 case 'email':
    181                         $user_id = wp_cache_get($value, 'useremail');
    182                         $field = 'user_email';
    183                         break;
    184                 case 'login':
    185                         $value = sanitize_user( $value );
    186                         $user_id = wp_cache_get($value, 'userlogins');
    187                         $field = 'user_login';
    188                         break;
    189                 default:
    190                         return false;
     157        $ids = array();
     158        foreach ( $users as $user ) {
     159                update_user_caches( $user );
     160                $ids[] = $user->ID;
    191161        }
    192 
    193          if ( false !== $user_id )
    194                 return get_userdata($user_id);
    195 
    196         if ( !$user = $wpdb->get_row( $wpdb->prepare("SELECT * FROM $wpdb->users WHERE $field = %s", $value) ) )
    197                 return false;
    198 
    199         _fill_user($user);
    200 
    201         return $user;
     162        update_meta_cache( 'user', $ids );
    202163}
    203164endif;
    204165
  • wp-includes/user.php

    diff --git a/wp-includes/user.php b/wp-includes/user.php
    index 68b2704..bb88f2d 100644
    a b function get_blogs_of_user( $id, $all = false ) { 
    680680        }
    681681
    682682        if ( false === $blogs ) {
    683                 $user = get_userdata( (int) $id );
    684                 if ( !$user )
     683                $userkeys = array_keys( get_user_meta( (int) $id ) );
     684                if ( empty( $userkeys ) )
    685685                        return false;
    686686
    687687                $blogs = $match = array();
    688                 $prefix_length = strlen($wpdb->base_prefix);
    689                 foreach ( (array) $user as $key => $value ) {
     688                $prefix_length = strlen( $wpdb->base_prefix );
     689                foreach ( $userkeys as $key ) {
    690690                        if ( $prefix_length && substr($key, 0, $prefix_length) != $wpdb->base_prefix )
    691691                                continue;
    692692                        if ( substr($key, -12, 12) != 'capabilities' )
    function delete_user_meta($user_id, $meta_key, $meta_value = '') { 
    792792 * @return mixed Will be an array if $single is false. Will be value of meta data field if $single
    793793 *  is true.
    794794 */
    795 function get_user_meta($user_id, $key, $single = false) {
     795function get_user_meta($user_id, $key = '', $single = false) {
    796796        return get_metadata('user', $user_id, $key, $single);
    797797}
    798798
    function wp_dropdown_users( $args = '' ) { 
    10421042}
    10431043
    10441044/**
    1045  * Add user meta data as properties to given user object.
    1046  *
    1047  * The finished user data is cached, but the cache is not used to fill in the
    1048  * user data for the given object. Once the function has been used, the cache
    1049  * should be used to retrieve user data. The intention is if the current data
    1050  * had been cached already, there would be no need to call this function.
    1051  *
    1052  * @access private
    1053  * @since 2.5.0
    1054  * @uses $wpdb WordPress database object for queries
    1055  *
    1056  * @param object $user The user data object.
    1057  */
    1058 function _fill_user( &$user ) {
    1059         $metavalues = get_user_metavalues(array($user->ID));
    1060         _fill_single_user($user, $metavalues[$user->ID]);
    1061 }
    1062 
    1063 /**
    1064  * Perform the query to get the $metavalues array(s) needed by _fill_user and _fill_many_users
    1065  *
    1066  * @since 3.0.0
    1067  * @param array $ids User ID numbers list.
    1068  * @return array of arrays. The array is indexed by user_id, containing $metavalues object arrays.
    1069  */
    1070 function get_user_metavalues($ids) {
    1071         $objects = array();
    1072 
    1073         $ids = array_map('intval', $ids);
    1074         foreach ( $ids as $id )
    1075                 $objects[$id] = array();
    1076 
    1077         $metas = update_meta_cache('user', $ids);
    1078 
    1079         foreach ( $metas as $id => $meta ) {
    1080                 foreach ( $meta as $key => $metavalues ) {
    1081                         foreach ( $metavalues as $value ) {
    1082                                 $objects[$id][] = (object)array( 'user_id' => $id, 'meta_key' => $key, 'meta_value' => $value);
    1083                         }
    1084                 }
    1085         }
    1086 
    1087         return $objects;
    1088 }
    1089 
    1090 /**
    1091  * Unserialize user metadata, fill $user object, then cache everything.
    1092  *
    1093  * @since 3.0.0
    1094  * @param object $user The User object.
    1095  * @param array $metavalues An array of objects provided by get_user_metavalues()
    1096  */
    1097 function _fill_single_user( &$user, &$metavalues ) {
    1098         global $wpdb;
    1099 
    1100         foreach ( $metavalues as $meta ) {
    1101                 $value = maybe_unserialize($meta->meta_value);
    1102                 // Keys used as object vars cannot have dashes.
    1103                 $key = str_replace('-', '', $meta->meta_key);
    1104                 $user->{$key} = $value;
    1105         }
    1106 
    1107         $level = $wpdb->prefix . 'user_level';
    1108         if ( isset( $user->{$level} ) )
    1109                 $user->user_level = $user->{$level};
    1110 
    1111         // For backwards compat.
    1112         if ( isset($user->first_name) )
    1113                 $user->user_firstname = $user->first_name;
    1114         if ( isset($user->last_name) )
    1115                 $user->user_lastname = $user->last_name;
    1116         if ( isset($user->description) )
    1117                 $user->user_description = $user->description;
    1118 
    1119         update_user_caches($user);
    1120 }
    1121 
    1122 /**
    1123  * Take an array of user objects, fill them with metas, and cache them.
    1124  *
    1125  * @since 3.0.0
    1126  * @param array $users User objects
    1127  */
    1128 function _fill_many_users( &$users ) {
    1129         $ids = array();
    1130         foreach( $users as $user_object ) {
    1131                 $ids[] = $user_object->ID;
    1132         }
    1133 
    1134         $metas = get_user_metavalues($ids);
    1135 
    1136         foreach ( $users as $user_object ) {
    1137                 if ( isset($metas[$user_object->ID]) ) {
    1138                         _fill_single_user($user_object, $metas[$user_object->ID]);
    1139                 }
    1140         }
    1141 }
    1142 
    1143 /**
    1144  * Sanitize every user field.
    1145  *
    1146  * If the context is 'raw', then the user object or array will get minimal santization of the int fields.
    1147  *
    1148  * @since 2.3.0
    1149  * @uses sanitize_user_field() Used to sanitize the fields.
    1150  *
    1151  * @param object|array $user The User Object or Array
    1152  * @param string $context Optional, default is 'display'. How to sanitize user fields.
    1153  * @return object|array The now sanitized User Object or Array (will be the same type as $user)
    1154  */
    1155 function sanitize_user_object($user, $context = 'display') {
    1156         if ( is_object($user) ) {
    1157                 if ( !isset($user->ID) )
    1158                         $user->ID = 0;
    1159                 if ( isset($user->data) )
    1160                         $vars = get_object_vars( $user->data );
    1161                 else
    1162                         $vars = get_object_vars($user);
    1163                 foreach ( array_keys($vars) as $field ) {
    1164                         if ( is_string($user->$field) || is_numeric($user->$field) )
    1165                                 $user->$field = sanitize_user_field($field, $user->$field, $user->ID, $context);
    1166                 }
    1167                 $user->filter = $context;
    1168         } else {
    1169                 if ( !isset($user['ID']) )
    1170                         $user['ID'] = 0;
    1171                 foreach ( array_keys($user) as $field )
    1172                         $user[$field] = sanitize_user_field($field, $user[$field], $user['ID'], $context);
    1173                 $user['filter'] = $context;
    1174         }
    1175 
    1176         return $user;
    1177 }
    1178 
    1179 /**
    11801045 * Sanitize user field based on context.
    11811046 *
    11821047 * Possible context values are:  'raw', 'edit', 'db', 'display', 'attribute' and 'js'. The
    function sanitize_user_field($field, $value, $user_id, $context) { 
    12631128 *
    12641129 * @param object $user User object to be cached
    12651130 */
    1266 function update_user_caches(&$user) {
     1131function update_user_caches($user) {
    12671132        wp_cache_add($user->ID, $user, 'users');
    12681133        wp_cache_add($user->user_login, $user->ID, 'userlogins');
    12691134        wp_cache_add($user->user_email, $user->ID, 'useremail');
    function update_user_caches(&$user) { 
    12781143 * @param int $id User ID
    12791144 */
    12801145function clean_user_cache($id) {
    1281         $user = new WP_User($id);
     1146        $user = WP_User::get_data_by( 'id', $id );
    12821147
    12831148        wp_cache_delete($id, 'users');
    12841149        wp_cache_delete($user->user_login, 'userlogins');
    function wp_insert_user($userdata) { 
    13891254        if ( !empty($ID) ) {
    13901255                $ID = (int) $ID;
    13911256                $update = true;
    1392                 $old_user_data = get_userdata($ID);
     1257                $old_user_data = WP_User::get_data_by( 'id', $ID );
    13931258        } else {
    13941259                $update = false;
    13951260                // Hash the password
    function wp_update_user($userdata) { 
    15471412        $ID = (int) $userdata['ID'];
    15481413
    15491414        // First, get all of the original fields
    1550         $user = get_userdata($ID);
     1415        $user = WP_User::get_data_by('id', $ID);
    15511416
    15521417        // Escape data pulled from DB.
    15531418        $user = add_magic_quotes(get_object_vars($user));