diff --git a/src/wp-includes/class-wp-query.php b/src/wp-includes/class-wp-query.php index a0d364976e..fb1fea61fb 100644 --- a/src/wp-includes/class-wp-query.php +++ b/src/wp-includes/class-wp-query.php @@ -627,6 +627,7 @@ class WP_Query { * @since 4.9.0 Introduced the `$comment_count` parameter. * @since 5.1.0 Introduced the `$meta_compare_key` parameter. * @since 5.3.0 Introduced the `$meta_type_key` parameter. + * @since 6.1.0 Introduced the `$update_menu_item_cache` parameter. * * @param string|array $query { * Optional. Array or string of Query parameters. diff --git a/src/wp-includes/nav-menu.php b/src/wp-includes/nav-menu.php index c018cf23f9..8df3cd2cc8 100644 --- a/src/wp-includes/nav-menu.php +++ b/src/wp-includes/nav-menu.php @@ -753,11 +753,11 @@ function wp_get_nav_menu_items( $menu, $args = array() ) { } /** - * Prime all linked objects to menu items. + * Updates post and term caches for all linked objects for a list of menu items. * * @since 6.1.0 * - * @param WP_Post[] $menu_items Array post objects of menu items. + * @param WP_Post[] $menu_items Array of menu item post objects. */ function update_menu_item_cache( $menu_items ) { $post_ids = array(); @@ -767,6 +767,7 @@ function update_menu_item_cache( $menu_items ) { if ( 'nav_menu_item' !== $menu_item->post_type ) { continue; } + $object_id = get_post_meta( $menu_item->ID, '_menu_item_object_id', true ); $type = get_post_meta( $menu_item->ID, '_menu_item_type', true ); diff --git a/tests/phpunit/tests/post/nav-menu.php b/tests/phpunit/tests/post/nav-menu.php index 02ee4cfe4a..2e38640fd2 100644 --- a/tests/phpunit/tests/post/nav-menu.php +++ b/tests/phpunit/tests/post/nav-menu.php @@ -204,8 +204,9 @@ class Tests_Post_Nav_Menu extends WP_UnitTestCase { /** * @ticket 55620 + * @covers update_menu_item_cache */ - public function test_update_menu_item_cache_primed_post() { + public function test_update_menu_item_cache_primed_posts() { $post_id = self::factory()->post->create(); wp_update_nav_menu_item( $this->menu_id, @@ -229,11 +230,12 @@ class Tests_Post_Nav_Menu extends WP_UnitTestCase { $args = $action->get_args(); $last = end( $args ); - $this->assertEqualSets( array( $post_id ), $last[1], '_prime_post_caches was not executed.' ); + $this->assertEqualSets( array( $post_id ), $last[1], '_prime_post_caches() was not executed.' ); } /** * @ticket 55620 + * @covers update_menu_item_cache */ public function test_update_menu_item_cache_primed_terms() { register_taxonomy( 'wptests_tax', 'post', array( 'hierarchical' => true ) ); @@ -260,7 +262,7 @@ class Tests_Post_Nav_Menu extends WP_UnitTestCase { $args = $action->get_args(); $last = end( $args ); - $this->assertEqualSets( array( $term_id ), $last[1], '_prime_term_caches was not executed.' ); + $this->assertEqualSets( array( $term_id ), $last[1], '_prime_term_caches() was not executed.' ); } /**