Make WordPress Core


Ignore:
Timestamp:
11/18/2015 07:58:01 PM (11 years ago)
Author:
wonderboymusic
Message:

Rewrite: alleviate conflicts between image attachment pages and posts when permalink structure is /%postname%/.

Adds unit test.

Props SergeyBiryukov.
Fixes #24612.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/tests/query/conditionals.php

    r35244 r35679  
    761761        }
    762762
     763        /**
     764         * @ticket 24612
     765         */
     766        public function test_is_single_with_slug_that_clashes_with_attachment() {
     767                $this->set_permalink_structure( '/%postname%/' );
     768
     769                $attachment_id = $this->factory->post->create( array(
     770                        'post_type'  => 'attachment',
     771                ) );
     772
     773                $post_id = $this->factory->post->create( array(
     774                        'post_title' => get_post( $attachment_id )->post_title
     775                ) );
     776
     777                $this->go_to( get_permalink( $post_id ) );
     778
     779                $q = $GLOBALS['wp_query'];
     780
     781                $this->assertTrue( $q->is_single() );
     782                $this->assertTrue( $q->is_single( $post_id ) );
     783                $this->assertFalse( $q->is_attachment() );
     784                $this->assertFalse( $q->is_404() );
     785
     786                $this->set_permalink_structure();
     787        }
     788
    763789        function test_is_page() {
    764790                $post_id = self::factory()->post->create( array( 'post_type' => 'page' ) );
Note: See TracChangeset for help on using the changeset viewer.