Changeset 54377
- Timestamp:
- 10/04/2022 03:31:04 AM (2 years ago)
- Location:
- trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/post.php
r54320 r54377 5788 5788 ); 5789 5789 $query = new WP_Query( $args ); 5790 $pages = $query-> get_posts();5790 $pages = $query->posts; 5791 5791 5792 5792 if ( empty( $pages ) ) { -
trunk/tests/phpunit/tests/post/getPageByTitle.php
r54271 r54377 316 316 $this->assertSame( $num_queries, get_num_queries(), 'Should not result in another database query.' ); 317 317 } 318 319 /** 320 * Ensure get_page_by_title() only runs the query once. 321 * 322 * @ticket 56721 323 * @covers ::get_page_by_title 324 */ 325 public function test_should_not_run_query_more_than_once() { 326 $page = self::factory()->post->create_and_get( 327 array( 328 'post_title' => 'some-page', 329 'post_type' => 'page', 330 ) 331 ); 332 333 // Use the `pre_get_posts` hook to ensure the query is only run once. 334 $ma = new MockAction(); 335 add_action( 'pre_get_posts', array( $ma, 'action' ) ); 336 337 get_page_by_title( 'some-page' ); 338 $this->assertSame( 1, $ma->get_call_count(), 'Query does not run exactly once.' ); 339 } 318 340 }
Note: See TracChangeset
for help on using the changeset viewer.