Ticket #30970: 30970.diff
| File 30970.diff, 2.1 KB (added by , 11 years ago) |
|---|
-
src/wp-includes/query.php
4627 4627 * @global int $more 4628 4628 * @global int $numpages 4629 4629 * 4630 * @param WP_Post $post Post data.4630 * @param WP_Post|stdClass|int $post WP_Post instace or Post ID/object, which will be converted into WP_Post. 4631 4631 * @return true True when finished. 4632 4632 */ 4633 4633 public function setup_postdata( $post ) { 4634 4634 global $id, $authordata, $currentday, $currentmonth, $page, $pages, $multipage, $more, $numpages; 4635 4635 4636 if ( ! ( $post instanceof WP_Post ) ) { 4637 $post = get_post( $post ); 4638 } 4639 4636 4640 $id = (int) $post->ID; 4637 4641 4638 4642 $authordata = get_userdata($post->post_author); … … 4701 4705 public function reset_postdata() { 4702 4706 if ( ! empty( $this->post ) ) { 4703 4707 $GLOBALS['post'] = $this->post; 4704 setup_postdata( $this->post );4708 $this->setup_postdata( $this->post ); 4705 4709 } 4706 4710 } 4707 4711 } … … 4772 4776 * 4773 4777 * @global WP_Query $wp_query 4774 4778 * 4775 * @param object $post Post data.4779 * @param WP_Post|stdClass|int $post WP_Post instace or Post ID/object, which will be converted into WP_Post. 4776 4780 * @return bool True when finished. 4777 4781 */ 4778 4782 function setup_postdata( $post ) { -
tests/phpunit/tests/query/setupPostdata.php
46 46 $this->assertSame( $p->ID, $GLOBALS['id'] ); 47 47 } 48 48 49 public function test_setup_by_id() { 50 $p = $this->factory->post->create_and_get(); 51 setup_postdata( $p->ID ); 52 53 $this->assertNotEmpty( $p->ID ); 54 $this->assertSame( $p->ID, $GLOBALS['id'] ); 55 } 56 57 public function test_fake_post() { 58 59 $fake = new stdClass; 60 $fake->ID = 100; 61 62 $this->assertNotSame( $fake->ID, $GLOBALS['id'] ); 63 } 64 49 65 public function test_authordata() { 50 66 $u = $this->factory->user->create_and_get(); 51 67 $p = $this->factory->post->create_and_get( array(
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)