Make WordPress Core


Ignore:
Timestamp:
04/07/2016 07:21:02 PM (8 years ago)
Author:
boonebgorges
Message:

Use __trashed suffix rather than -%trashed% for trashed post slugs.

Percent signs are reserved characters in URIs. As such, it was impossible for
plugins to route requests to trashed posts, as happens in bbPress. The new
__trashed suffix should be sufficiently unique.

Also adds a test that demonstrates that the __trashed suffix can be
appended to slugs that contain the suffix somewhere other than the end of
the string.

Props netweb, ericlewis.
Fixes #11863.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/tests/post/wpInsertPost.php

    r36607 r37165  
    1616        ) );
    1717        wp_trash_post( $trashed_about_page_id );
    18         $this->assertEquals( 'about-%trashed%', get_post( $trashed_about_page_id )->post_name );
     18        $this->assertEquals( 'about__trashed', get_post( $trashed_about_page_id )->post_name );
     19    }
     20
     21    /**
     22     * @ticket 11863
     23     */
     24    public function test_trashed_suffix_should_be_added_to_post_with__trashed_in_slug() {
     25        $trashed_about_page_id = self::factory()->post->create( array(
     26            'post_type' => 'page',
     27            'post_title' => 'About',
     28            'post_status' => 'publish',
     29            'post_name' => 'foo__trashed__foo',
     30        ) );
     31        wp_trash_post( $trashed_about_page_id );
     32        $this->assertEquals( 'foo__trashed__foo__trashed', get_post( $trashed_about_page_id )->post_name );
    1933    }
    2034
     
    5064        ) );
    5165
    52         $this->assertEquals( 'about-%trashed%', get_post( $trashed_about_page_id )->post_name );
     66        $this->assertEquals( 'about__trashed', get_post( $trashed_about_page_id )->post_name );
    5367        $this->assertEquals( 'about', get_post( $about_page_id )->post_name );
    5468    }
Note: See TracChangeset for help on using the changeset viewer.