WordPress.org

Make WordPress Core

Ticket #21682: 21682.3.diff

File 21682.3.diff, 1.9 KB (added by ninnypants, 5 years ago)
  • src/wp-includes/class-wp-rewrite.php

     
    254254         * @access private
    255255         * @var array
    256256         */
    257         var $endpoints;
     257        var $endpoints = array();
    258258
    259259        /**
    260260         * Whether to write every mod_rewrite rule for WordPress into the .htaccess file.
     
    16691669                        $query_var = $name;
    16701670                }
    16711671                $this->endpoints[] = array( $places, $name, $query_var );
     1672                $this->endpoints = array_unique( $this->endpoints, SORT_REGULAR );
    16721673
    16731674                if ( $query_var ) {
    16741675                        $wp->add_query_var( $query_var );
     
    18021803         * @access public
    18031804         */
    18041805        public function init() {
    1805                 $this->extra_rules = $this->non_wp_rules = $this->endpoints = array();
     1806                $this->extra_rules = $this->non_wp_rules = array();
    18061807                $this->permalink_structure = get_option('permalink_structure');
    18071808                $this->front = substr($this->permalink_structure, 0, strpos($this->permalink_structure, '%'));
    18081809                $this->root = '';
  • tests/phpunit/tests/rewrite/addRewriteEndpoint.php

     
    101101                add_rewrite_endpoint( 'page_endpoint', EP_PAGES );
    102102                flush_rewrite_rules();
    103103
    104                 $this->go_to( get_permalink( self::$test_page_id ) . 'page_endpoint/foo/' );
     104                $this->go_to( get_permalink( self::$test_page_id ) . 'page_endpoint/baz/' );
    105105
    106106                $this->assertTrue( is_page( self::$test_page_id ) );
    107                 $this->assertSame( 'foo', get_query_var( 'page_endpoint' ) );
     107                $this->assertSame( 'baz', get_query_var( 'page_endpoint' ) );
    108108
    109                 $this->go_to( home_url( 'page_endpoint/foo/' ) );
     109                $this->go_to( home_url( 'page_endpoint/baz/' ) );
    110110
    111111                $this->assertTrue( is_404() );
    112112                $this->assertSame( '', get_query_var( 'page_endpoint' ) );