Make WordPress Core

Ticket #35902: 35902.diff

File 35902.diff, 1.3 KB (added by swissspidy, 10 years ago)
  • src/wp-includes/query.php

    diff --git src/wp-includes/query.php src/wp-includes/query.php
    index 053f4e9..8ab5f32 100644
    class WP_Query { 
    45024502
    45034503                $page_obj = $this->get_queried_object();
    45044504
    4505                 $page = (array) $page;
     4505                $page = array_map( 'strval', (array) $page );
    45064506
    45074507                if ( in_array( (string) $page_obj->ID, $page ) ) {
    45084508                        return true;
  • tests/phpunit/tests/query/conditionals.php

    diff --git tests/phpunit/tests/query/conditionals.php tests/phpunit/tests/query/conditionals.php
    index a1f3665..3e1c036 100644
    class Tests_Query_Conditionals extends WP_UnitTestCase { 
    10171017                $this->assertFalse( is_page_template( array( 'test.php' ) ) );
    10181018                $this->assertTrue( is_page_template( array('test.php', 'example.php') ) );
    10191019        }
     1020
     1021        /**
     1022         * @ticket 35902
     1023         */
     1024        function test_page_should_cast_argument_to_string() {
     1025                $page_1 = self::factory()->post->create( array( 'post_type' => 'page', 'post_title' => 'About' ) );
     1026                $page_2 = self::factory()->post->create( array( 'post_type' => 'page', 'post_title' => "$page_1/7 About" ) );
     1027                $this->go_to( get_permalink( $page_2 ) );
     1028                $this->assertQueryTrue( 'is_page', 'is_singular' );
     1029                $this->assertTrue( is_page( $page_2 ) );
     1030                $this->assertFalse( is_page( $page_1 ) );
     1031        }
    10201032}