Make WordPress Core

Ticket #15545: 15545.diff

File 15545.diff, 2.0 KB (added by mdawaffe, 14 years ago)
  • wp-includes/user.php

     
    10371037        foreach ( $ids as $id )
    10381038                $objects[$id] = array();
    10391039
    1040         update_meta_cache('user', $ids);
     1040        $metas = update_meta_cache('user', $ids);
    10411041
    1042         foreach ( $ids as $id ) {
    1043                 $meta = get_metadata('user', $id);
     1042        foreach ( $metas as $id => $meta ) {
    10441043                foreach ( $meta as $key => $metavalues ) {
    10451044                        foreach ( $metavalues as $value ) {
    10461045                                $objects[$id][] = (object)array( 'user_id' => $id, 'meta_key' => $key, 'meta_value' => $value);
  • wp-includes/meta.php

     
    259259        $meta_cache = wp_cache_get($object_id, $meta_type . '_meta');
    260260
    261261        if ( !$meta_cache ) {
    262                 update_meta_cache($meta_type, $object_id);
    263                 $meta_cache = wp_cache_get($object_id, $meta_type . '_meta');
     262                $meta_cache = update_meta_cache( $meta_type, array( $object_id ) );
     263                $meta_cache = $meta_cache[$object_id];
    264264        }
    265265
    266266        if ( !$meta_key )
     
    309309
    310310        $cache_key = $meta_type . '_meta';
    311311        $ids = array();
     312        $cache = array();
    312313        foreach ( $object_ids as $id ) {
    313                 if ( false === wp_cache_get($id, $cache_key) )
     314                $cached_object = wp_cache_get( $id, $cache_key );
     315                if ( false === $cached_object )
    314316                        $ids[] = $id;
     317                else
     318                        $cache[$id] = $cached_object;
    315319        }
    316320
    317321        if ( empty( $ids ) )
    318                 return false;
     322                return $cache;
    319323
    320324        // Get meta info
    321325        $id_list = join(',', $ids);
    322         $cache = array();
    323326        $meta_list = $wpdb->get_results( $wpdb->prepare("SELECT $column, meta_key, meta_value FROM $table WHERE $column IN ($id_list)",
    324327                $meta_type), ARRAY_A );
    325328
     
    343346        foreach ( $ids as $id ) {
    344347                if ( ! isset($cache[$id]) )
    345348                        $cache[$id] = array();
     349                wp_cache_add( $id, $cache[$id], $cache_key );
    346350        }
    347351
    348         foreach ( array_keys($cache) as $object)
    349                 wp_cache_add($object, $cache[$object], $cache_key);
    350 
    351352        return $cache;
    352353}
    353354