[wp-trac] Re: [WordPress Trac] #3964: Aggressive matching in rewrite.php leads to "nothing matches" errors with custom rewrite endpoints

WordPress Trac wp-trac at lists.automattic.com
Sun Mar 18 09:09:09 GMT 2007


#3964: Aggressive matching in rewrite.php leads to "nothing matches" errors with
custom rewrite endpoints
-------------------------------------------------------------+--------------
 Reporter:  jhodgdon                                         |        Owner:  westi   
     Type:  defect                                           |       Status:  assigned
 Priority:  normal                                           |    Milestone:  2.2     
Component:  General                                          |      Version:  2.1.2   
 Severity:  normal                                           |   Resolution:          
 Keywords:  rewrite reporter-feedback has-patch 2nd-opinion  |  
-------------------------------------------------------------+--------------
Changes (by westi):

  * keywords:  rewrite reporter-feedback 2nd-opinion => rewrite reporter-
               feedback has-patch 2nd-opinion

Comment:

 The above patch fixes EP_ROOT to do what it should do.

 Test Plugin:
 {{{
 <?php
 /*
 Plugin Name: Rewrite
 Description: Tests rewrite code.
 Version: 0.1
 */
 function test_add_endpoint()
 {
     global $wp_rewrite;
     add_rewrite_endpoint('test',EP_ALL);
     ?><!--<?php
     print_r($wp_rewrite->generate_rewrite_rules($wp_rewrite->root . '/',
 EP_ROOT));
 print_r($wp_rewrite->generate_rewrite_rules($wp_rewrite->permalink_structure,
 EP_PERMALINK));
     ?>--><?php
 }

 add_action('init', 'test_add_endpoint');
 ?>
 }}}

 Output:
 {{{
 (
     [feed/(feed|rdf|rss|rss2|atom)/?$] => index.php?&feed=$1
     [(feed|rdf|rss|rss2|atom)/?$] => index.php?&feed=$1
     [page/?([0-9]{1,})/?$] => index.php?&paged=$1
     [test(/(.*))?/?$] => index.php?&test=$2
 )
 Array
 (
     [(.+?)/([0-9]{4})/([^/]+)/trackback/?$] =>
 index.php?category_name=$1&year=$2&name=$3&tb=1
     [(.+?)/([0-9]{4})/([^/]+)/feed/(feed|rdf|rss|rss2|atom)/?$] =>
 index.php?category_name=$1&year=$2&name=$3&feed=$4
     [(.+?)/([0-9]{4})/([^/]+)/(feed|rdf|rss|rss2|atom)/?$] =>
 index.php?category_name=$1&year=$2&name=$3&feed=$4
     [(.+?)/([0-9]{4})/([^/]+)/page/?([0-9]{1,})/?$] =>
 index.php?category_name=$1&year=$2&name=$3&paged=$4
     [(.+?)/([0-9]{4})/([^/]+)/test(/(.*))?/?$] =>
 index.php?category_name=$1&year=$2&name=$3&test=$5
     [.+?/[0-9]{4}/[^/]+/([^/]+)/test(/(.*))?/?$] =>
 index.php?attachment=$1?&test=$2
     [.+?/[0-9]{4}/[^/]+/attachment/([^/]+)/test(/(.*))?/?$] =>
 index.php?attachment=$1?&test=$2
     [(.+?)/([0-9]{4})/([^/]+)(/[0-9]+)?/?$] =>
 index.php?category_name=$1&year=$2&name=$3&page=$4
     [.+?/[0-9]{4}/[^/]+/([^/]+)/?$] => index.php?attachment=$1
     [.+?/[0-9]{4}/[^/]+/([^/]+)/trackback/?$] =>
 index.php?attachment=$1&tb=1
     [.+?/[0-9]{4}/[^/]+/([^/]+)/feed/(feed|rdf|rss|rss2|atom)/?$] =>
 index.php?attachment=$1&feed=$2
     [.+?/[0-9]{4}/[^/]+/([^/]+)/(feed|rdf|rss|rss2|atom)/?$] =>
 index.php?attachment=$1&feed=$2
     [.+?/[0-9]{4}/[^/]+/attachment/([^/]+)/?$] => index.php?attachment=$1
     [.+?/[0-9]{4}/[^/]+/attachment/([^/]+)/trackback/?$] =>
 index.php?attachment=$1&tb=1
 [.+?/[0-9]{4}/[^/]+/attachment/([^/]+)/feed/(feed|rdf|rss|rss2|atom)/?$]
 => index.php?attachment=$1&feed=$2
     [.+?/[0-9]{4}/[^/]+/attachment/([^/]+)/(feed|rdf|rss|rss2|atom)/?$] =>
 index.php?attachment=$1&feed=$2
     [(.+?)/([0-9]{4})/feed/(feed|rdf|rss|rss2|atom)/?$] =>
 index.php?category_name=$1&year=$2&feed=$3
     [(.+?)/([0-9]{4})/(feed|rdf|rss|rss2|atom)/?$] =>
 index.php?category_name=$1&year=$2&feed=$3
     [(.+?)/([0-9]{4})/page/?([0-9]{1,})/?$] =>
 index.php?category_name=$1&year=$2&paged=$3
     [(.+?)/([0-9]{4})/test(/(.*))?/?$] =>
 index.php?category_name=$1&year=$2&test=$4
     [(.+?)/([0-9]{4})/?$] => index.php?category_name=$1&year=$2
     [(.+?)/feed/(feed|rdf|rss|rss2|atom)/?$] =>
 index.php?category_name=$1&feed=$2
     [(.+?)/(feed|rdf|rss|rss2|atom)/?$] =>
 index.php?category_name=$1&feed=$2
     [(.+?)/page/?([0-9]{1,})/?$] => index.php?category_name=$1&paged=$2
     [(.+?)/test(/(.*))?/?$] => index.php?category_name=$1&test=$3
     [(.+?)/?$] => index.php?category_name=$1
 )
 }}}

-- 
Ticket URL: <http://trac.wordpress.org/ticket/3964#comment:13>
WordPress Trac <http://trac.wordpress.org/>
WordPress blogging software


More information about the wp-trac mailing list