Ticket #35816: 35816.patch
File 35816.patch, 1.4 KB (added by , 9 years ago) |
---|
-
src/wp-includes/query.php
3788 3788 $this->posts = array(); 3789 3789 } 3790 3790 3791 /** 3792 * Fires after the query has been set up and executed. 3793 * 3794 * Note: If using conditional tags, use the method versions within the passed instance 3795 * (e.g. $this->is_main_query() instead of is_main_query()). This is because the functions 3796 * like is_main_query() test against the global $wp_query instance, not the passed one. 3797 * 3798 * @since 4.5.0 3799 * 3800 * @param WP_Query &$this The WP_Query instance (passed by reference). 3801 */ 3802 do_action_ref_array( 'after_get_posts', array( &$this ) ); 3803 3791 3804 return $this->posts; 3792 3805 } 3793 3806 -
tests/phpunit/tests/query/setupPostdata.php
380 380 } 381 381 } 382 382 383 /** 384 * @ticket 35816 385 */ 386 public function test_after_get_posts_is_called() { 387 $query = new WP_Query; 388 389 // Add a listener to the new 'after_get_posts' action. 390 $action = new MockAction(); 391 add_action( 'after_get_posts', array( &$action, 'action' ) ); 392 393 // Execute the get_posts() method. 394 $query->get_posts(); 395 396 $this->assertEquals( 1, $action->get_call_count() ); 397 } 398 383 399 }