Make WordPress Core

Changeset 56811


Ignore:
Timestamp:
10/09/2023 11:01:15 PM (11 months ago)
Author:
peterwilsoncc
Message:

Query: Rename _prime_post_parents_caches() for clarity.

Change the name of _prime_post_parents_caches() to _prime_post_parent_id_caches() to make it clearer only the parent post ID is cached rather than the entire post parent object.

Follow up to [56763].

Props spacedmonkey, joemcgill, peterwilsoncc.
See #59188.

Location:
trunk
Files:
3 edited

Legend:

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

    r56763 r56811  
    31923192                        return $this->posts;
    31933193                    } elseif ( 'id=>parent' === $q['fields'] ) {
    3194                         _prime_post_parents_caches( $post_ids );
     3194                        _prime_post_parent_id_caches( $post_ids );
    31953195
    31963196                        /** @var int[] */
  • trunk/src/wp-includes/post.php

    r56773 r56811  
    77987798
    77997799/**
    7800  * Prime post parent caches.
     7800 * Prime the cache containing the parent ID of various post objects.
    78017801 *
    78027802 * @global wpdb $wpdb WordPress database abstraction object.
     
    78067806 * @param int[] $ids ID list.
    78077807 */
    7808 function _prime_post_parents_caches( array $ids ) {
     7808function _prime_post_parent_id_caches( array $ids ) {
    78097809    global $wpdb;
    78107810
  • trunk/tests/phpunit/tests/post/primePostParentsCaches.php

    r56766 r56811  
    11<?php
    22/**
    3  * Test `_prime_post_parents_caches()`.
     3 * Test `_prime_post_parent_id_caches()`.
    44 *
    55 * @package WordPress
     
    77
    88/**
    9  * Test class for `_prime_post_parents_caches()`.
     9 * Test class for `_prime_post_parent_id_caches()`.
    1010 *
    1111 * @group post
    1212 * @group cache
    1313 *
    14  * @covers ::_prime_post_parents_caches
     14 * @covers ::_prime_post_parent_id_caches
    1515 */
    16 class Tests_Post_PrimePostParentsCaches extends WP_UnitTestCase {
     16class Tests_Post_PrimePostParentIdCaches extends WP_UnitTestCase {
    1717
    1818    /**
     
    3535     * @ticket 59188
    3636     */
    37     public function test_prime_post_parents_caches() {
     37    public function test_prime_post_parent_id_caches() {
    3838        $post_id = self::$posts[0];
    3939
    4040        $before_num_queries = get_num_queries();
    41         _prime_post_parents_caches( array( $post_id ) );
     41        _prime_post_parent_id_caches( array( $post_id ) );
    4242        $num_queries = get_num_queries() - $before_num_queries;
    4343
     
    4949     * @ticket 59188
    5050     */
    51     public function test_prime_post_parents_caches_multiple() {
     51    public function test_prime_post_parent_id_caches_multiple() {
    5252        $before_num_queries = get_num_queries();
    53         _prime_post_parents_caches( self::$posts );
     53        _prime_post_parent_id_caches( self::$posts );
    5454        $num_queries = get_num_queries() - $before_num_queries;
    5555
     
    6161     * @ticket 59188
    6262     */
    63     public function test_prime_post_parents_caches_multiple_runs() {
    64         _prime_post_parents_caches( self::$posts );
     63    public function test_prime_post_parent_id_caches_multiple_runs() {
     64        _prime_post_parent_id_caches( self::$posts );
    6565        $before_num_queries = get_num_queries();
    66         _prime_post_parents_caches( self::$posts );
     66        _prime_post_parent_id_caches( self::$posts );
    6767        $num_queries = get_num_queries() - $before_num_queries;
    6868
     
    7373     * @ticket 59188
    7474     */
    75     public function test_prime_post_parents_caches_update() {
     75    public function test_prime_post_parent_id_caches_update() {
    7676        $page_id            = self::factory()->post->create(
    7777            array(
     
    8181        );
    8282        $before_num_queries = get_num_queries();
    83         _prime_post_parents_caches( array( $page_id ) );
     83        _prime_post_parent_id_caches( array( $page_id ) );
    8484        $num_queries = get_num_queries() - $before_num_queries;
    8585
     
    9595
    9696        $before_num_queries = get_num_queries();
    97         _prime_post_parents_caches( array( $page_id ) );
     97        _prime_post_parent_id_caches( array( $page_id ) );
    9898        $num_queries = get_num_queries() - $before_num_queries;
    9999
     
    105105     * @ticket 59188
    106106     */
    107     public function test_prime_post_parents_caches_delete() {
     107    public function test_prime_post_parent_id_caches_delete() {
    108108        $parent_page_id     = self::factory()->post->create(
    109109            array(
     
    118118        );
    119119        $before_num_queries = get_num_queries();
    120         _prime_post_parents_caches( array( $page_id ) );
     120        _prime_post_parent_id_caches( array( $page_id ) );
    121121        $num_queries = get_num_queries() - $before_num_queries;
    122122
Note: See TracChangeset for help on using the changeset viewer.