diff --git a/src/wp-includes/class-wp-query.php b/src/wp-includes/class-wp-query.php index ac0faa3edb..10e7a3c7fa 100644 --- a/src/wp-includes/class-wp-query.php +++ b/src/wp-includes/class-wp-query.php @@ -3260,14 +3260,14 @@ class WP_Query { if ( ! empty( $sticky_posts ) ) { $stickies = get_posts( array( - 'cache_results' => $q['cache_results'], - 'lazy_load_term_meta' => $q['lazy_load_term_meta'], 'post__in' => $sticky_posts, 'post_type' => $post_type, 'post_status' => 'publish', 'suppress_filters' => $q['suppress_filters'], + 'cache_results' => $q['cache_results'], 'update_post_meta_cache' => $q['update_post_meta_cache'], 'update_post_term_cache' => $q['update_post_term_cache'], + 'lazy_load_term_meta' => $q['lazy_load_term_meta'], ) ); diff --git a/tests/phpunit/tests/query/stickies.php b/tests/phpunit/tests/query/stickies.php index 9ff07c63a4..3f02ae32e5 100644 --- a/tests/phpunit/tests/query/stickies.php +++ b/tests/phpunit/tests/query/stickies.php @@ -109,7 +109,7 @@ class Tests_Query_Stickies extends WP_UnitTestCase { /** * @ticket 36907 */ - public function test_stickies_nest_query() { + public function test_stickies_should_obey_parameters_from_the_main_query() { $filter = new MockAction(); add_filter( 'posts_pre_query', array( $filter, 'filter' ), 10, 2 ); $this->go_to( '/' ); @@ -119,10 +119,10 @@ class Tests_Query_Stickies extends WP_UnitTestCase { $this->assertNotEmpty( $sticky_query_vars['posts_per_page'] ); $this->assertSame( $query_vars['suppress_filters'], $sticky_query_vars['suppress_filters'] ); + $this->assertSame( $query_vars['cache_results'], $sticky_query_vars['cache_results'] ); $this->assertSame( $query_vars['update_post_meta_cache'], $sticky_query_vars['update_post_meta_cache'] ); $this->assertSame( $query_vars['update_post_term_cache'], $sticky_query_vars['update_post_term_cache'] ); $this->assertSame( $query_vars['lazy_load_term_meta'], $sticky_query_vars['lazy_load_term_meta'] ); - $this->assertSame( $query_vars['cache_results'], $sticky_query_vars['cache_results'] ); $this->assertTrue( $sticky_query_vars['ignore_sticky_posts'] ); $this->assertTrue( $sticky_query_vars['no_found_rows'] ); }