Make WordPress Core

Changeset 53508


Ignore:
Timestamp:
06/15/2022 01:35:28 PM (4 years ago)
Author:
SergeyBiryukov
Message:

REST API: Some documentation and test improvements for update_menu_item_cache():

  • Make the function description more specific, for consistency with other similar functions.
  • Add a @since note for the $update_menu_item_cache parameter of WP_Query::parse_query().
  • Add missing @covers tags for the unit tests.

Follow-up to [53504].

See #55620.

Location:
trunk
Files:
3 edited

Legend:

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

    r53504 r53508  
    628628         * @since 5.1.0 Introduced the `$meta_compare_key` parameter.
    629629         * @since 5.3.0 Introduced the `$meta_type_key` parameter.
     630         * @since 6.1.0 Introduced the `$update_menu_item_cache` parameter.
    630631         *
    631632         * @param string|array $query {
  • trunk/src/wp-includes/nav-menu.php

    r53504 r53508  
    754754
    755755/**
    756  * Prime all linked objects to menu items.
     756 * Updates post and term caches for all linked objects for a list of menu items.
    757757 *
    758758 * @since 6.1.0
    759759 *
    760  * @param WP_Post[] $menu_items Array post objects of menu items.
     760 * @param WP_Post[] $menu_items Array of menu item post objects.
    761761 */
    762762function update_menu_item_cache( $menu_items ) {
     
    768768                        continue;
    769769                }
     770
    770771                $object_id = get_post_meta( $menu_item->ID, '_menu_item_object_id', true );
    771772                $type      = get_post_meta( $menu_item->ID, '_menu_item_type', true );
  • trunk/tests/phpunit/tests/post/nav-menu.php

    r53504 r53508  
    205205        /**
    206206         * @ticket 55620
    207          */
    208         public function test_update_menu_item_cache_primed_post() {
     207         * @covers update_menu_item_cache
     208         */
     209        public function test_update_menu_item_cache_primed_posts() {
    209210                $post_id = self::factory()->post->create();
    210211                wp_update_nav_menu_item(
     
    230231                $args = $action->get_args();
    231232                $last = end( $args );
    232                 $this->assertEqualSets( array( $post_id ), $last[1], '_prime_post_caches was not executed.' );
     233                $this->assertEqualSets( array( $post_id ), $last[1], '_prime_post_caches() was not executed.' );
    233234        }
    234235
    235236        /**
    236237         * @ticket 55620
     238         * @covers update_menu_item_cache
    237239         */
    238240        public function test_update_menu_item_cache_primed_terms() {
     
    261263                $args = $action->get_args();
    262264                $last = end( $args );
    263                 $this->assertEqualSets( array( $term_id ), $last[1], '_prime_term_caches was not executed.' );
     265                $this->assertEqualSets( array( $term_id ), $last[1], '_prime_term_caches() was not executed.' );
    264266        }
    265267
Note: See TracChangeset for help on using the changeset viewer.