WordPress.org

Make WordPress Core

Changeset 37481


Ignore:
Timestamp:
05/22/2016 04:18:22 PM (3 years ago)
Author:
boonebgorges
Message:

In get_page_by_path(), values fetched from cache should obey $output param.

Introduced in [37479].

Props spacedmonkey.
Fixes #36711.

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/post.php

    r37479 r37481  
    42464246            return;
    42474247        } else {
    4248             return get_post( $cached );
     4248            return get_post( $cached, $output );
    42494249        }
    42504250    }
  • trunk/tests/phpunit/tests/post/getPageByPath.php

    r37479 r37481  
    243243        $this->assertSame( $num_queries, $wpdb->num_queries );
    244244    }
     245
     246    /**
     247     * @ticket 37611
     248     */
     249    public function test_output_param_should_be_obeyed_for_cached_value() {
     250        $page = self::factory()->post->create( array(
     251            'post_type' => 'page',
     252            'post_name' => 'foo',
     253        ) );
     254
     255        // Prime cache.
     256        $found = get_page_by_path( 'foo' );
     257        $this->assertSame( $page, $found->ID );
     258
     259        $object = get_page_by_path( 'foo', OBJECT );
     260        $this->assertInternalType( 'object', $object );
     261        $this->assertSame( $page, $object->ID );
     262
     263        $array_n = get_page_by_path( 'foo', ARRAY_N );
     264        $this->assertInternalType( 'array', $array_n );
     265        $this->assertSame( $page, $array_n[0] );
     266
     267        $array_a = get_page_by_path( 'foo', ARRAY_A );
     268        $this->assertInternalType( 'array', $array_a );
     269        $this->assertSame( $page, $array_a['ID'] );
     270    }
    245271}
Note: See TracChangeset for help on using the changeset viewer.