Ticket #16687: polish.16687.diff
File polish.16687.diff, 5.1 KB (added by , 14 years ago) |
---|
-
wp-includes/class-wp.php
diff --git a/wp-includes/class-wp.php b/wp-includes/class-wp.php index a1bc2f1..5fad51f 100644
a b class WP { 184 184 $this->request = $request; 185 185 186 186 // Look for matches. 187 $request_match = $request; 188 if ( empty( $req_uri ) ) { 189 // An empty request could only match against ^$ regex 190 if ( isset( $rewrite['$'] ) ) { 191 $this->matched_rule = '$'; 192 $query = $rewrite['$']; 193 $matches = array(''); 194 } 195 } else if ( $req_uri != 'wp-app.php' ) { 196 foreach ( (array) $rewrite as $match => $query ) { 197 // If the requesting file is the anchor of the match, prepend it to the path info. 198 if ( ! empty($req_uri) && strpos($match, $req_uri) === 0 && $req_uri != $request ) 199 $request_match = $req_uri . '/' . $request; 200 201 if ( preg_match("#^$match#", $request_match, $matches) || 202 preg_match("#^$match#", urldecode($request_match), $matches) ) { 203 204 if ( $wp_rewrite->use_verbose_page_rules && 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 210 // Got a match. 211 $this->matched_rule = $match; 212 break; 213 } 214 } 215 } 216 217 if ( isset( $this->matched_rule ) ) { 218 // Trim the query of everything up to the '?'. 219 $query = preg_replace("!^.+\?!", '', $query); 220 221 // Substitute the substring matches into the query. 222 $query = addslashes(WP_MatchesMapRegex::apply($query, $matches)); 187 $result = $wp_rewrite->find_match( $request, $req_uri, $rewrite ); 223 188 224 $this->matched_query = $query; 189 if ( $result ) { 190 list( $this->matched_rule, $this->matched_query ) = $result; 225 191 226 // Parse the query. 227 parse_str($query, $perma_query_vars); 192 parse_str( $this->matched_query, $perma_query_vars ); 228 193 229 194 // If we're processing a 404 request, clear the error var 230 195 // since we found something. -
wp-includes/rewrite.php
diff --git a/wp-includes/rewrite.php b/wp-includes/rewrite.php index 4502db1..956ac4b 100644
a b function url_to_postid($url) { 304 304 $request = $url; 305 305 306 306 // Look for matches. 307 $request_match = $request; 308 foreach ( (array)$rewrite as $match => $query) { 309 310 // If the requesting file is the anchor of the match, prepend it 311 // to the path info. 312 if ( !empty($url) && ($url != $request) && (strpos($match, $url) === 0) ) 313 $request_match = $url . '/' . $request; 314 315 if ( preg_match("!^$match!", $request_match, $matches) ) { 316 317 if ( $wp_rewrite->use_verbose_page_rules && 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 323 // Got a match. 324 // Trim the query of everything up to the '?'. 325 $query = preg_replace("!^.+\?!", '', $query); 326 327 // Substitute the substring matches into the query. 328 $query = addslashes(WP_MatchesMapRegex::apply($query, $matches)); 307 $result = $wp_rewrite->find_match( $request, $url, $rewrite ); 308 if ( $result ) { 309 list( $match, $query ) = $result; 329 310 330 311 // Filter out non-public query vars 331 312 global $wp; … … function url_to_postid($url) { 342 323 return $query->post->ID; 343 324 else 344 325 return 0; 345 }346 326 } 347 327 return 0; 348 328 } … … class WP_Rewrite { 1969 1949 function __construct() { 1970 1950 $this->init(); 1971 1951 } 1952 1953 /** 1954 * Go through a list of rewrite rules and find a match 1955 * 1956 * @since 3.3.0 1957 * @access private 1958 */ 1959 function find_match( $request, $req_uri, $rewrite ) { 1960 $found = false; 1961 1962 $request_match = $request; 1963 if ( empty( $req_uri ) ) { 1964 // An empty request could only match against ^$ regex 1965 if ( isset( $rewrite['$'] ) ) { 1966 $match = '$'; 1967 $query = $rewrite['$']; 1968 $matches = array(''); 1969 $found = true; 1970 } 1971 } else if ( $req_uri != 'wp-app.php' ) { 1972 foreach ( (array) $rewrite as $match => $query ) { 1973 // If the requesting file is the anchor of the match, prepend it to the path info. 1974 if ( ! empty($req_uri) && strpos($match, $req_uri) === 0 && $req_uri != $request ) 1975 $request_match = $req_uri . '/' . $request; 1976 1977 if ( preg_match("#^$match#", $request_match, $matches) || 1978 preg_match("#^$match#", urldecode($request_match), $matches) ) { 1979 1980 if ( $this->use_verbose_page_rules == true && preg_match( '/pagename=\$matches\[([0-9]+)\]/', $query, $varmatch ) ) { 1981 // this is a verbose page match, lets check to be sure about it 1982 if ( ! get_page_by_path( $matches[ $varmatch[1] ] ) ) 1983 continue; 1984 } 1985 1986 // Got a match. 1987 $found = true; 1988 break; 1989 } 1990 } 1991 } 1992 1993 if ( $found ) { 1994 // Trim the query of everything up to the '?'. 1995 $query = preg_replace("!^.+\?!", '', $query); 1996 1997 // Substitute the substring matches into the query. 1998 $query = addslashes(WP_MatchesMapRegex::apply($query, $matches)); 1999 2000 return array( $match, $query ); 2001 } 2002 2003 return false; 2004 } 1972 2005 } 1973 2006 1974 2007 ?>