Ticket #13413: 13413.patch
| File 13413.patch, 8.4 KB (added by , 16 years ago) |
|---|
-
wp-includes/query.php
### Eclipse Workspace Patch 1.0 #P wordpress-trunk
1605 1605 * 1606 1606 * @return array List of posts. 1607 1607 */ 1608 function &get_posts() {1608 function get_posts() { 1609 1609 global $wpdb, $user_ID, $_wp_using_ext_object_cache; 1610 1610 1611 1611 do_action_ref_array('pre_get_posts', array(&$this)); … … 1946 1946 // Tags 1947 1947 if ( '' != $q['tag'] ) { 1948 1948 if ( strpos($q['tag'], ',') !== false ) { 1949 $tags = preg_split('/[,\ s]+/', $q['tag']);1949 $tags = preg_split('/[,\r\n\t ]+/', $q['tag']); 1950 1950 foreach ( (array) $tags as $tag ) { 1951 1951 $tag = sanitize_term_field('slug', $tag, 0, 'post_tag', 'db'); 1952 1952 $q['tag_slug__in'][] = $tag; 1953 1953 } 1954 } else if ( preg_match('/[+\ s]+/', $q['tag']) || !empty($q['cat']) ) {1955 $tags = preg_split('/[+\ s]+/', $q['tag']);1954 } else if ( preg_match('/[+\r\n\t ]+/', $q['tag']) || !empty($q['cat']) ) { 1955 $tags = preg_split('/[+\r\n\t ]+/', $q['tag']); 1956 1956 foreach ( (array) $tags as $tag ) { 1957 1957 $tag = sanitize_term_field('slug', $tag, 0, 'post_tag', 'db'); 1958 1958 $q['tag_slug__and'][] = $tag; … … 2690 2690 * @param string $query URL query string. 2691 2691 * @return array List of posts. 2692 2692 */ 2693 function &query($query) {2693 function query($query) { 2694 2694 $this->parse_query($query); 2695 2695 return $this->get_posts(); 2696 2696 } -
wp-includes/classes.php
128 128 * 129 129 * @param array|string $extra_query_vars Set the extra query variables. 130 130 */ 131 function parse_request( $extra_query_vars = '') {131 function parse_request( $extra_query_vars = '' ) { 132 132 global $wp_rewrite; 133 133 134 $this->query_vars = array();135 $taxonomy_query_vars = array();134 $this->query_vars = array(); 135 $taxonomy_query_vars = array(); 136 136 $post_type_query_vars = array(); 137 137 138 if ( is_array( $extra_query_vars) )139 $this->extra_query_vars = &$extra_query_vars;140 else if (! empty( $extra_query_vars))141 parse_str( $extra_query_vars, $this->extra_query_vars);138 if ( is_array( $extra_query_vars ) ) 139 $this->extra_query_vars = $extra_query_vars; 140 else if (! empty( $extra_query_vars ) ) 141 parse_str( $extra_query_vars, $this->extra_query_vars ); 142 142 143 143 // Process PATH_INFO, REQUEST_URI, and 404 for permalinks. 144 144 … … 150 150 $error = '404'; 151 151 $this->did_permalink = true; 152 152 153 if ( isset($_SERVER['PATH_INFO']) ) 154 $pathinfo = $_SERVER['PATH_INFO']; 153 $pathinfo = ''; 154 if ( isset( $_SERVER['PATH_INFO'] ) ) { 155 $pathinfo_array = explode( '?', $_SERVER['PATH_INFO'] ); 156 $pathinfo = str_replace("%", "%25", $pathinfo_array[0] ); 157 $pathinfo_array = null; 158 } 159 160 $req_uri_array = explode( '?', $_SERVER['REQUEST_URI'] ); 161 $req_uri = $req_uri_array[0]; 162 $req_uri_array = null; 163 164 $home_path_array = parse_url( home_url() ); 165 if ( isset( $home_path_array['path'] ) ) 166 $home_path = $home_path_array['path']; 155 167 else 156 $pathinfo = '';157 $pathinfo_array = explode('?', $pathinfo);158 $pathinfo = str_replace("%", "%25", $pathinfo_array[0]);159 $req_uri = $_SERVER['REQUEST_URI'];160 $req_uri_array = explode('?', $req_uri);161 $req_uri = $req_uri_array[0];162 $self = $_SERVER['PHP_SELF'];163 $home_path = parse_url(home_url());164 if ( isset($home_path['path']) )165 $home_path = $home_path['path'];166 else167 168 $home_path = ''; 168 $home_path = trim($home_path, '/'); 169 $home_path_array = null; 170 $home_path = trim( $home_path, '/' ); 169 171 170 172 // Trim path info from the end and the leading home path from the 171 // front. For path info requests, this leaves us with the requesting173 // front. For path info requests, this leaves us with the requesting 172 174 // filename, if any. For 404 requests, this leaves us with the 173 175 // requested permalink. 174 $req_uri = str_replace($pathinfo, '', rawurldecode($req_uri)); 175 $req_uri = trim($req_uri, '/'); 176 $req_uri = preg_replace("|^$home_path|", '', $req_uri); 177 $req_uri = trim($req_uri, '/'); 178 $pathinfo = trim($pathinfo, '/'); 179 $pathinfo = preg_replace("|^$home_path|", '', $pathinfo); 180 $pathinfo = trim($pathinfo, '/'); 181 $self = trim($self, '/'); 182 $self = preg_replace("|^$home_path|", '', $self); 183 $self = trim($self, '/'); 176 $req_uri = str_replace( $pathinfo, '', rawurldecode( $req_uri ) ); 177 $req_uri = trim( $req_uri, '/' ); 178 $req_uri = preg_replace( "|^$home_path|", '', $req_uri ); 179 $req_uri = trim( $req_uri, '/' ); 180 $pathinfo = trim( $pathinfo, '/' ); 181 $pathinfo = preg_replace( "|^$home_path|", '', $pathinfo ); 182 $pathinfo = trim( $pathinfo, '/' ); 183 $self = $_SERVER['PHP_SELF']; 184 $self = trim( $self, '/' ); 185 $self = preg_replace( "|^$home_path|", '', $self ); 186 $self = trim( $self, '/' ); 184 187 185 188 // The requested permalink is in $pathinfo for path info requests and 186 // $req_uri for other requests.187 if ( ! empty( $pathinfo) && !preg_match('|^.*' . $wp_rewrite->index . '$|', $pathinfo) ) {189 // $req_uri for other requests. 190 if ( ! empty( $pathinfo ) && !preg_match( '|^.*' . $wp_rewrite->index . '$|', $pathinfo ) ) { 188 191 $request = $pathinfo; 189 192 } else { 190 193 // If the request uri is the index, blank it out so that we don't try to match it against a rule. … … 197 200 198 201 // Look for matches. 199 202 $request_match = $request; 200 foreach ( (array)$rewrite as $match => $query) {203 foreach ( $rewrite as $match => $query) { 201 204 // Don't try to match against AtomPub calls 202 205 if ( $req_uri == 'wp-app.php' ) 203 206 break; 204 207 205 208 // If the requesting file is the anchor of the match, prepend it 206 209 // to the path info. 207 if ( ( ! empty($req_uri)) && (strpos($match, $req_uri) === 0) && ($req_uri != $request) )210 if ( ( ! empty ( $req_uri ) ) && ( strpos( $match, $req_uri ) === 0 ) && ( $req_uri != $request ) ) 208 211 $request_match = $req_uri . '/' . $request; 209 212 210 if ( preg_match( "#^$match#", $request_match, $matches) ||211 preg_match( "#^$match#", urldecode($request_match), $matches) ) {213 if ( preg_match( "#^$match#", $request_match, $matches ) || 214 preg_match( "#^$match#", urldecode( $request_match ), $matches ) ) { 212 215 // Got a match. 213 216 $this->matched_rule = $match; 214 217 215 218 // Trim the query of everything up to the '?'. 216 $query = preg_replace("!^.+\?!", '', $query); 217 219 $query = preg_replace( "!^.+\?!", '', $query ); 218 220 // Substitute the substring matches into the query. 219 $query = addslashes( WP_MatchesMapRegex::apply($query, $matches));221 $query = addslashes( WP_MatchesMapRegex::apply( $query, $matches ) ); 220 222 221 223 $this->matched_query = $query; 222 224 223 225 // Parse the query. 224 parse_str( $query, $perma_query_vars);226 parse_str( $query, $perma_query_vars ); 225 227 226 // If we're processing a 404 request, clear the error var 228 // If we're processing a 404 request, clear the error vars 227 229 // since we found something. 228 if ( isset($_GET['error']) )229 unset($_GET['error']);230 $_GET['error'] = null; 231 $error = null; 230 232 231 if ( isset($error) )232 unset($error);233 234 233 break; 235 234 } 236 235 } 237 236 238 237 // If req_uri is empty or if it is a request for ourself, unset error. 239 if ( empty($request) || $req_uri == $self || strpos($_SERVER['PHP_SELF'], 'wp-admin/') !== false ) { 240 if ( isset($_GET['error']) ) 241 unset($_GET['error']); 238 if ( empty( $request ) || $req_uri == $self || strpos( $_SERVER['PHP_SELF'], 'wp-admin/' ) !== false ) { 239 $_GET['error'] = null; 240 $error = null; 241 if ( isset( $perma_query_vars ) && strpos( $_SERVER['PHP_SELF'], 'wp-admin/' ) !== false ) 242 unset( $perma_query_vars ); 242 243 243 if ( isset($error) )244 unset($error);245 246 if ( isset($perma_query_vars) && strpos($_SERVER['PHP_SELF'], 'wp-admin/') !== false )247 unset($perma_query_vars);248 249 244 $this->did_permalink = false; 250 245 } 251 246 } 252 247 253 $this->public_query_vars = apply_filters( 'query_vars', $this->public_query_vars);248 $this->public_query_vars = apply_filters( 'query_vars', $this->public_query_vars ); 254 249 255 250 foreach ( $GLOBALS['wp_taxonomies'] as $taxonomy => $t ) 256 251 if ( $t->query_var ) … … 502 497 */ 503 498 function main($query_args = '') { 504 499 $this->init(); 505 $this->parse_request($query_args); 500 $this->parse_request($query_args); 506 501 $this->send_headers(); 507 502 $this->query_posts(); 508 503 $this->handle_404();