[wp-trac] [WordPress Trac] #16687: %postname% permalinks should not trigger verbose rewrite rules

WordPress Trac wp-trac at lists.automattic.com
Thu Aug 11 23:00:41 UTC 2011


#16687: %postname% permalinks should not trigger verbose rewrite rules
----------------------------+------------------
 Reporter:  nacin           |       Owner:
     Type:  task (blessed)  |      Status:  new
 Priority:  normal          |   Milestone:  3.3
Component:  Rewrite Rules   |     Version:
 Severity:  normal          |  Resolution:
 Keywords:                  |
----------------------------+------------------

Comment (by scribu):

 Coding style: Instead of:

 {{{
 if ( $wp_rewrite->use_verbose_page_rules == true &&
 preg_match('/pagename=\$([^&\[]+)\[([0-9]+)\]/',$query,$varmatch) ) {
 }}}

 you can just write:

 {{{
 if ( $wp_rewrite->use_verbose_page_rules &&
 preg_match('/pagename=\$([^&\[]+)\[([0-9]+)\]/',$query,$varmatch) ) {
 }}}

 and it's pretty tricky to figure out what this line does:

 {{{if ( ! get_page_by_path(${$varmatch[1]}[$varmatch[2]]) )}}}

 More importantly, why does this block of code appear twice:

 {{{
 if ( $wp_rewrite->use_verbose_page_rules == true &&
 preg_match('/pagename=\$([^&\[]+)\[([0-9]+)\]/',$query,$varmatch) ) {
   // this is a verbose page match, lets check to be sure about it
   if ( ! get_page_by_path(${$varmatch[1]}[$varmatch[2]]) )
     continue;
 }
 }}}

 If it's really needed in two places, it should be factored into a helper
 function.

-- 
Ticket URL: <http://core.trac.wordpress.org/ticket/16687#comment:45>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software


More information about the wp-trac mailing list