Ticket #16687: no_verbose_ver3.diff
File no_verbose_ver3.diff, 6.6 KB (added by , 13 years ago) |
---|
-
wp-includes/class-wp.php
200 200 201 201 if ( preg_match("#^$match#", $request_match, $matches) || 202 202 preg_match("#^$match#", urldecode($request_match), $matches) ) { 203 204 if ( $wp_rewrite->use_verbose_page_rules == true && preg_match('/pagename=\$([^&\[]+)\[([0-9]+)\]/',$query,$varmatch) ) { 205 // this is a verbose page match, lets check to be sure about it 206 if ( ! get_page_by_path(${$varmatch[1]}[$varmatch[2]]) ) 207 continue; 208 } 209 203 210 // Got a match. 204 211 $this->matched_rule = $match; 205 212 break; -
wp-includes/post.php
3147 3147 function get_page_by_path($page_path, $output = OBJECT, $post_type = 'page') { 3148 3148 global $wpdb; 3149 3149 $null = null; 3150 $page_path = rawurlencode(urldecode($page_path));3151 $page_path = str_replace('%2F', '/', $page_path);3152 $page_path = str_replace('%20', ' ', $page_path);3153 $page_paths = '/' . trim($page_path, '/');3154 $leaf_path = sanitize_title(basename($page_paths));3155 $page_paths = explode('/', $page_paths);3156 $full_path = '';3157 foreach ( (array) $page_paths as $pathdir )3158 $full_path .= ( $pathdir != '' ? '/' : '' ) . sanitize_title($pathdir);3159 3150 3160 $pages = $wpdb->get_results( $wpdb->prepare( "SELECT ID, post_name, post_parent FROM $wpdb->posts WHERE post_name = %s AND (post_type = %s OR post_type = 'attachment')", $leaf_path, $post_type )); 3151 $page_path = rawurlencode(urldecode($page_path)); 3152 $page_path = str_replace('%2F', '/', $page_path); 3153 $page_path = str_replace('%20', ' ', $page_path); 3154 $parts = explode( '/', trim( $page_path, '/' ) ); 3155 $parts = array_map( 'esc_sql', $parts ); 3156 $parts = array_map( 'sanitize_title', $parts ); 3161 3157 3162 if ( empty($pages) )3163 return $null;3158 $in_string = "'". implode( "','", $parts ) . "'"; 3159 $pages = $wpdb->get_results( $wpdb->prepare( "SELECT ID, post_name, post_parent FROM $wpdb->posts WHERE post_name IN ({$in_string}) AND (post_type = %s OR post_type = 'attachment')", $post_type ), OBJECT_K ); 3164 3160 3161 $revparts = array_reverse( $parts ); 3162 3163 $foundid = 0; 3165 3164 foreach ( $pages as $page ) { 3166 $path = '/' . $leaf_path; 3167 $curpage = $page; 3168 while ( $curpage->post_parent != 0 ) { 3169 $post_parent = $curpage->post_parent; 3170 $curpage = wp_cache_get( $post_parent, 'posts' ); 3171 if ( false === $curpage ) 3172 $curpage = $wpdb->get_row( $wpdb->prepare( "SELECT ID, post_name, post_parent FROM $wpdb->posts WHERE ID = %d and post_type = %s", $post_parent, $post_type ) ); 3173 $path = '/' . $curpage->post_name . $path; 3165 if ( $page->post_name == $revparts[0] ) { 3166 $count = 0; 3167 if ( $page->post_parent != 0 ) { 3168 if ( null === ( $parent_page = $pages[ $page->post_parent ] ) ) 3169 continue; 3170 3171 while ( $parent_page->ID != 0 ) { 3172 $count++; 3173 if ( $parent_page->post_name != $revparts[ $count ] ) 3174 break; 3175 $parent_page = $pages[ $parent_page->post_parent ]; 3176 } 3177 3178 if ( $parent_page->ID == 0 && $count+1 == count($revparts) ) { 3179 $foundid = $page->ID; 3180 break; 3181 } 3182 } else if ( count($revparts) == 1 ) { 3183 $foundid = $page->ID; 3184 break; 3185 } 3174 3186 } 3175 3176 if ( $path == $full_path )3177 return get_page($page->ID, $output, $post_type);3178 3187 } 3179 3188 3189 if ( $foundid ) 3190 return get_page($foundid, $output, $post_type); 3191 3180 3192 return $null; 3181 3193 } 3182 3194 -
wp-includes/rewrite.php
306 306 // Look for matches. 307 307 $request_match = $request; 308 308 foreach ( (array)$rewrite as $match => $query) { 309 309 310 // If the requesting file is the anchor of the match, prepend it 310 311 // to the path info. 311 312 if ( !empty($url) && ($url != $request) && (strpos($match, $url) === 0) ) 312 313 $request_match = $url . '/' . $request; 313 314 314 315 if ( preg_match("!^$match!", $request_match, $matches) ) { 316 317 if ( $wp_rewrite->use_verbose_page_rules == true && preg_match('/pagename=\$([^&\[]+)\[([0-9]+)\]/',$query,$varmatch) ) { 318 // this is a verbose page match, lets check to be sure about it 319 if ( ! get_page_by_path(${$varmatch[1]}[$varmatch[2]]) ) 320 continue; 321 } 322 315 323 // Got a match. 316 324 // Trim the query of everything up to the '?'. 317 325 $query = preg_replace("!^.+\?!", '', $query); … … 813 821 $rewrite_rules = array(); 814 822 $page_structure = $this->get_page_permastruct(); 815 823 816 if ( ! $this->use_verbose_page_rules ) { 817 $this->add_rewrite_tag('%pagename%', "(.+?)", 'pagename='); 818 $rewrite_rules = array_merge($rewrite_rules, $this->generate_rewrite_rules($page_structure, EP_PAGES)); 819 return $rewrite_rules; 820 } 821 822 $page_uris = $this->page_uri_index(); 823 $uris = $page_uris[0]; 824 $attachment_uris = $page_uris[1]; 825 826 if ( is_array( $attachment_uris ) ) { 827 foreach ( $attachment_uris as $uri => $pagename ) { 828 $this->add_rewrite_tag('%pagename%', "($uri)", 'attachment='); 829 $rewrite_rules = array_merge($rewrite_rules, $this->generate_rewrite_rules($page_structure, EP_PAGES)); 830 } 831 } 832 if ( is_array( $uris ) ) { 833 foreach ( $uris as $uri => $pagename ) { 834 $this->add_rewrite_tag('%pagename%', "($uri)", 'pagename='); 835 $rewrite_rules = array_merge($rewrite_rules, $this->generate_rewrite_rules($page_structure, EP_PAGES)); 836 } 837 } 838 824 // the extra .? at the beginning prevents clashes with other regex's in thie structure 825 $this->add_rewrite_tag('%pagename%', "(.?.+?)", 'pagename='); 826 $rewrite_rules = array_merge($rewrite_rules, $this->generate_rewrite_rules($page_structure, EP_PAGES)); 839 827 return $rewrite_rules; 840 828 } 841 829 … … 1558 1546 1559 1547 // Put them together. 1560 1548 if ( $this->use_verbose_page_rules ) 1561 $this->rules = array_merge($this->extra_rules_top, $robots_rewrite, $default_feeds, $registration_pages, $ page_rewrite, $root_rewrite, $comments_rewrite, $search_rewrite, $author_rewrite, $date_rewrite, $post_rewrite, $this->extra_rules);1549 $this->rules = array_merge($this->extra_rules_top, $robots_rewrite, $default_feeds, $registration_pages, $root_rewrite, $comments_rewrite, $search_rewrite, $author_rewrite, $date_rewrite, $page_rewrite, $post_rewrite, $this->extra_rules); 1562 1550 else 1563 1551 $this->rules = array_merge($this->extra_rules_top, $robots_rewrite, $default_feeds, $registration_pages, $root_rewrite, $comments_rewrite, $search_rewrite, $author_rewrite, $date_rewrite, $post_rewrite, $page_rewrite, $this->extra_rules); 1564 1552