WordPress.org

Make WordPress Core


Ignore:
Timestamp:
01/09/2015 04:39:56 PM (6 years ago)
Author:
boonebgorges
Message:

In get_permalink(), don't resolve to pretty permalink if post has 'future' status.

We already do this for other non-public statuses, to prevent leaking non-public
information about unpublished posts.

Props e.mazovetskiy, CalEvans.
Fixes #30910.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/tests/link.php

    r30401 r31114  
    287287        $this->assertEquals( '/this-is-a-test/?redirect=https://example.org/a-different-test-post/', $relative_link );
    288288    }
     289
     290    /**
     291     * @ticket 30910
     292     */
     293    public function test_get_permalink_should_not_reveal_post_name_for_post_with_post_status_future() {
     294        update_option( 'permalink_structure','/%year%/%monthnum%/%day%/%postname%/' );
     295
     296        flush_rewrite_rules();
     297
     298        $p = $this->factory->post->create( array(
     299            'post_status' => 'publish',
     300            'post_date'   => strftime( '%Y-%m-%d %H:%M:%S', strtotime( '+1 day' ) )
     301        ) );
     302
     303        $non_pretty_permalink = add_query_arg( 'p', $p, trailingslashit( home_url() ) );
     304
     305        $this->assertEquals( $non_pretty_permalink, get_permalink( $p ) );
     306    }
     307
     308    /**
     309     * @ticket 30910
     310     */
     311    public function test_get_permalink_should_not_reveal_post_name_for_cpt_with_post_status_future() {
     312        update_option( 'permalink_structure','/%year%/%monthnum%/%day%/%postname%/' );
     313
     314        register_post_type( 'wptests_pt', array( 'public' => true ) );
     315
     316        flush_rewrite_rules();
     317
     318        $p = $this->factory->post->create( array(
     319            'post_status' => 'future',
     320            'post_type'   => 'wptests_pt',
     321            'post_date'   => strftime( '%Y-%m-%d %H:%M:%S', strtotime( '+1 day' ) )
     322        ) );
     323
     324        $non_pretty_permalink = add_query_arg( array(
     325            'post_type' => 'wptests_pt',
     326            'p' => $p,
     327        ), trailingslashit( home_url() ) );
     328
     329        $this->assertEquals( $non_pretty_permalink, get_permalink( $p ) );
     330    }
    289331}
Note: See TracChangeset for help on using the changeset viewer.