WordPress.org

Make WordPress Core

Ticket #39992: 39992.3.diff

File 39992.3.diff, 1.1 KB (added by birgire, 2 years ago)
  • src/wp-includes/post-template.php

    diff --git src/wp-includes/post-template.php src/wp-includes/post-template.php
    index b80ac4d..61575af 100644
    function get_the_content( $more_link_text = null, $strip_teaser = false ) { 
    262262
    263263        $post = get_post();
    264264
     265        if( empty( $post ) ) {
     266                return '';
     267        }
     268
    265269        if ( null === $more_link_text ) {
    266270                $more_link_text = sprintf(
    267271                        '<span aria-label="%1$s">%2$s</span>',
  • tests/phpunit/tests/post/output.php

    diff --git tests/phpunit/tests/post/output.php tests/phpunit/tests/post/output.php
    index cc1e4ea..bc89470 100644
    EOF; 
    5757                $this->assertEquals( strip_ws( $expected ), strip_ws( get_echo( 'the_content' ) ) );
    5858        }
    5959
     60        /**
     61         * @ticket 39992
     62         */
     63        function test_get_the_content_should_return_empty_string_with_no_global_post_object() {               
     64                unset( $GLOBALS['post'] );               
     65                $this->assertEquals( '', get_the_content() );
     66        }
     67
    6068        function test_the_content_shortcode() {
    6169                $post_content = <<<EOF
    6270[dumptag foo="bar" baz="123"]