WordPress.org

Make WordPress Core

Ticket #35486: 35486.diff

File 35486.diff, 1.4 KB (added by swissspidy, 4 years ago)
  • src/wp-includes/post-template.php

    diff --git src/wp-includes/post-template.php src/wp-includes/post-template.php
    index 4cc8573..5ceed59 100644
    function get_the_excerpt( $post = null ) { 
    372372                return '';
    373373        }
    374374
    375         if ( post_password_required() ) {
     375        if ( post_password_required( $post ) ) {
    376376                return __( 'There is no excerpt because this is a protected post.' );
    377377        }
    378378
  • tests/phpunit/tests/post/output.php

    diff --git tests/phpunit/tests/post/output.php tests/phpunit/tests/post/output.php
    index 63b9aad..6026a2b 100644
    EOF; 
    199199
    200200        /**
    201201         * @ticket 27246
     202         * @ticket 35486
    202203         */
    203204        public function test_the_excerpt_password_protected_post() {
    204                 $GLOBALS['post'] = self::factory()->post->create_and_get( array( 'post_excerpt' => 'Post excerpt', 'post_password' => '1234' ) );
     205                $post = self::factory()->post->create_and_get( array( 'post_excerpt' => 'Post excerpt', 'post_password' => '1234' ) );
     206                $this->assertSame( 'There is no excerpt because this is a protected post.', get_the_excerpt( $post ) );
     207
     208                $GLOBALS['post'] = $post;
    205209                $this->assertSame( "<p>There is no excerpt because this is a protected post.</p>\n", get_echo( 'the_excerpt' ) );
    206                 $this->assertSame( 'There is no excerpt because this is a protected post.', get_the_excerpt() );
    207210        }
    208211
    209212        /**