Changeset 45285
- Timestamp:
- 05/04/2019 08:59:11 PM (6 years ago)
- Location:
- trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/class-wp-query.php
r44966 r45285 4209 4209 $numpages = $elements['numpages']; 4210 4210 4211 /** 4212 * Fires once the post data has been setup. 4213 * 4214 * @since 2.8.0 4215 * @since 4.1.0 Introduced `$this` parameter. 4216 * 4217 * @param WP_Post $post The Post object (passed by reference). 4218 * @param WP_Query $this The current Query object (passed by reference). 4219 */ 4220 do_action_ref_array( 'the_post', array( &$post, &$this ) ); 4221 4211 4222 return true; 4212 4223 } … … 4299 4310 } 4300 4311 4301 /**4302 * Fires once the post data has been setup.4303 *4304 * @since 2.8.04305 * @since 4.1.0 Introduced `$this` parameter.4306 *4307 * @param WP_Post $post The Post object (passed by reference).4308 * @param WP_Query $this The current Query object (passed by reference).4309 */4310 do_action_ref_array( 'the_post', array( &$post, &$this ) );4311 4312 4312 $elements = compact( 'id', 'authordata', 'currentday', 'currentmonth', 'page', 'pages', 'multipage', 'more', 'numpages' ); 4313 4313 -
trunk/tests/phpunit/tests/query/setupPostdata.php
r42343 r45285 9 9 10 10 protected $global_data = array(); 11 12 protected $pages_global; 11 13 12 14 public function setUp() { … … 417 419 } 418 420 421 /** 422 * @ticket 47114 423 * 424 * setup_postdata() should set the globals before `the_post` action is fired. 425 */ 426 public function test_the_post_action() { 427 $post = self::factory()->post->create_and_get(); 428 add_action( 'the_post', array( $this, 'the_post_action_callback' ) ); 429 430 setup_postdata( $post ); 431 432 $this->assertEquals( $GLOBALS['pages'], $this->pages_global ); 433 } 434 435 /** 436 * Helpers 437 */ 438 public function the_post_action_callback() { 439 $this->pages_global = $GLOBALS['pages']; 440 } 419 441 }
Note: See TracChangeset
for help on using the changeset viewer.