Make WordPress Core

Ticket #47114: 47114.2.diff

File 47114.2.diff, 1.8 KB (added by jorbin, 6 years ago)
  • src/wp-includes/class-wp-query.php

     
    42084208                $more         = $elements['more'];
    42094209                $numpages     = $elements['numpages'];
    42104210
     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
    42114222                return true;
    42124223        }
    42134224
     
    42984309                        $multipage = 0;
    42994310                }
    43004311
    4301                 /**
    4302                  * Fires once the post data has been setup.
    4303                  *
    4304                  * @since 2.8.0
    4305                  * @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 
    43124312                $elements = compact( 'id', 'authordata', 'currentday', 'currentmonth', 'page', 'pages', 'multipage', 'more', 'numpages' );
    43134313
    43144314                return $elements;
  • tests/phpunit/tests/query/setupPostdata.php

     
    416416                }
    417417        }
    418418
     419
     420        /**
     421         * @ticket 47114
     422         */
     423        public function test_the_post_action() {
     424                $post = self::factory()->post->create_and_get();
     425                add_action( 'the_post', function() {
     426                        $this->pages = $GLOBALS['pages'];
     427                } );
     428
     429                setup_postdata( $post );
     430
     431                $this->assertEquals( $GLOBALS['pages'], $this->pages );
     432        }
    419433}