Make WordPress Core

Changeset 25404


Ignore:
Timestamp:
09/12/2013 05:30:01 PM (12 years ago)
Author:
wonderboymusic
Message:

Fix the failing Tests_Link::test_wp_get_shortlink() assertion:

  • wp_get_shortlink() was firing a notice when reading $post->ID while $post was null in some cases
  • Before the assertions that assume $GLOBALS['post'] is not set, call unset( $GLOBALS['post'] ); - there was global spillage from other tests

See #25282.

Location:
trunk
Files:
2 edited

Legend:

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

    r25340 r25404  
    24182418    } elseif ( 'post' == $context ) {
    24192419        $post = get_post( $id );
    2420         $post_id = $post->ID;
     2420        if ( ! empty( $post->ID ) )
     2421            $post_id = $post->ID;
    24212422    }
    24222423
  • trunk/tests/phpunit/tests/link.php

    r25030 r25404  
    3535        // Basic case
    3636        $this->assertEquals( get_permalink( $post_id ), wp_get_shortlink( $post_id, 'post' ) );
     37
     38        unset( $GLOBALS['post'] );
    3739
    3840        // Global post is not set
Note: See TracChangeset for help on using the changeset viewer.