WordPress.org

Make WordPress Core

Changeset 41315


Ignore:
Timestamp:
08/25/2017 04:15:27 PM (2 years ago)
Author:
joemcgill
Message:

Media: Prime post caches in 'wp_make_content_images_responsive()'.

In [38296] we replaced get_post_meta() with wp_get_attachment_metadata()
so that attachment metadata could be consistently filtered. However, this
results in extra post queries which were previously avoided.

This uses _prime_post_caches() instead of update_meta_cache() to improve
post caching before looping through all images to retrieve attachment metadata.

Props dlh.
Fixes #40490.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/media.php

    r41234 r41315  
    13361336    if ( count( $attachment_ids ) > 1 ) {
    13371337        /*
    1338          * Warm object cache for use with 'get_post_meta()'.
    1339          *
    1340          * To avoid making a database call for each image, a single query
    1341          * warms the object cache with the meta information for all images.
     1338         * Warm the object cache with post and meta information for all found
     1339         * images to avoid making individual database calls.
    13421340         */
    1343         update_meta_cache( 'post', array_keys( $attachment_ids ) );
     1341        _prime_post_caches( array_keys( $attachment_ids ), false, true );
    13441342    }
    13451343
Note: See TracChangeset for help on using the changeset viewer.