Make WordPress Core


Ignore:
Timestamp:
10/12/2023 11:39:05 PM (16 months ago)
Author:
peterwilsoncc
Message:

Query: Cache post parent IDs in posts group.

Move the cache of post parent IDs from the dedicated group post_parents to posts. This maintains backward compatibility for clearing all post object related data by calling wp_cache_flush_group( 'posts' ).

Post parent IDs are now cached with with the prefix post_parent: in the posts group.

Follow up to [56763].

Props spacedmonkey, joemcgill, peterwilsoncc.
See #59188.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/tests/query/cacheResults.php

    r56763 r56925  
    739739        $query1->query( $args );
    740740
    741         $post_ids = wp_list_pluck( $query1->posts, 'ID' );
    742         wp_cache_delete_multiple( $post_ids, 'post_parent' );
     741        $post_ids   = wp_list_pluck( $query1->posts, 'ID' );
     742        $cache_keys = array_map(
     743            function ( $post_id ) {
     744                return "post_parent:{$post_id}";
     745            },
     746            $post_ids
     747        );
     748
     749        wp_cache_delete_multiple( $cache_keys, 'posts' );
    743750
    744751        $queries_before = get_num_queries();
Note: See TracChangeset for help on using the changeset viewer.