Make WordPress Core

Ticket #20875: 20875-update_meta_cache.diff

File 20875-update_meta_cache.diff, 1.2 KB (added by spacedmonkey, 8 years ago)
  • src/wp-includes/meta.php

     
    830830                $object_ids = explode( ',', $object_ids );
    831831        }
    832832
    833         $object_ids = array_map( 'intval', $object_ids );
    834 
    835         $cache_key = $meta_type . '_meta';
    836         $ids       = array();
    837         $cache     = array();
    838         foreach ( $object_ids as $id ) {
    839                 $cached_object = wp_cache_get( $id, $cache_key );
    840                 if ( false === $cached_object ) {
     833        $object_ids   = array_map( 'intval', $object_ids );
     834        $group        = $meta_type . '_meta';
     835        $ids          = array();
     836        $cache        = array();
     837        $groups       = array( $group => $object_ids );
     838        $cache_values = wp_cache_get_multiple( $groups );
     839        foreach ( $cache_values[ $group ] as $id => $value ) {
     840                if ( false === $value ) {
    841841                        $ids[] = $id;
    842842                } else {
    843                         $cache[ $id ] = $cached_object;
     843                        $cache[ $id ] = $value;
    844844                }
    845845        }
    846846
     
    876876                if ( ! isset( $cache[ $id ] ) ) {
    877877                        $cache[ $id ] = array();
    878878                }
    879                 wp_cache_add( $id, $cache[ $id ], $cache_key );
     879                wp_cache_add( $id, $cache[ $id ], $group );
    880880        }
    881881
    882882        return $cache;