diff options
| author | donncha <donncha@7be80a69-a1ef-0310-a953-fb0f7c49ff36> | 2005-11-18 13:31:37 +0000 |
|---|---|---|
| committer | donncha <donncha@7be80a69-a1ef-0310-a953-fb0f7c49ff36> | 2005-11-18 13:31:37 +0000 |
| commit | 2b56b90f06b0018f0dba866e2d799cda640d9597 (patch) | |
| tree | 5c7ff6836df5f6a9539847b49738e5665c06e498 /wp-inst/wp-includes/classes.php | |
| parent | 2f31acafe53edd3619b85a16fe1692dee7339a6b (diff) | |
| download | wordpress-mu-2b56b90f06b0018f0dba866e2d799cda640d9597.tar.gz wordpress-mu-2b56b90f06b0018f0dba866e2d799cda640d9597.tar.xz wordpress-mu-2b56b90f06b0018f0dba866e2d799cda640d9597.zip | |
WP Merge
git-svn-id: http://svn.automattic.com/wordpress-mu/trunk@439 7be80a69-a1ef-0310-a953-fb0f7c49ff36
Diffstat (limited to 'wp-inst/wp-includes/classes.php')
| -rw-r--r-- | wp-inst/wp-includes/classes.php | 138 |
1 files changed, 67 insertions, 71 deletions
diff --git a/wp-inst/wp-includes/classes.php b/wp-inst/wp-includes/classes.php index 99c2b3a..56502b4 100644 --- a/wp-inst/wp-includes/classes.php +++ b/wp-inst/wp-includes/classes.php @@ -601,11 +601,13 @@ class WP_Query { // Apply post-paging filters on where and join. Only plugins that // manipulate paging queries should use these hooks. $where = apply_filters('posts_where_paged', $where); - $where .= " GROUP BY $wpdb->posts.ID"; + $groupby = " $wpdb->posts.ID "; + $groupby = apply_filters('posts_groupby', $groupby); $join = apply_filters('posts_join_paged', $join); $orderby = "post_" . $q['orderby']; $orderby = apply_filters('posts_orderby', $orderby); - $request = " SELECT $distinct * FROM $wpdb->posts $join WHERE 1=1".$where." ORDER BY " . $orderby . " $limits"; + $request = " SELECT $distinct * FROM $wpdb->posts $join WHERE 1=1" . $where . " GROUP BY " . $groupby . " ORDER BY " . $orderby . " $limits"; + $request = apply_filters('posts_request', $request); $this->posts = $wpdb->get_results($request); @@ -1412,85 +1414,66 @@ class WP { $extra_query_vars = array(); // Process PATH_INFO, REQUEST_URI, and 404 for permalinks. - if ((isset($_GET['error']) && $_GET['error'] == '404') || - ((! empty($_SERVER['PATH_INFO'])) && - ('/' != $_SERVER['PATH_INFO']) && - (false === strpos($_SERVER['PATH_INFO'], '.php')) - ) || - (false === strpos($_SERVER['REQUEST_URI'], '.php')) - ) { - $this->did_permalink = true; + // Fetch the rewrite rules. + $rewrite = $wp_rewrite->wp_rewrite_rules(); + if (! empty($rewrite)) { // If we match a rewrite rule, this will be cleared. $error = '404'; + $this->did_permalink = true; - // Fetch the rewrite rules. - $rewrite = $wp_rewrite->wp_rewrite_rules(); - - if (! empty($rewrite)) { - $pathinfo = $_SERVER['PATH_INFO']; - $pathinfo_array = explode('?', $pathinfo); - $pathinfo = $pathinfo_array[0]; - $req_uri = $_SERVER['REQUEST_URI']; - $req_uri_array = explode('?', $req_uri); - $req_uri = $req_uri_array[0]; - $home_path = parse_url(get_settings('home')); - $home_path = $home_path['path']; - - // Trim path info from the end and the leading home path from the - // front. For path info requests, this leaves us with the requesting - // filename, if any. For 404 requests, this leaves us with the - // requested permalink. - $req_uri = str_replace($pathinfo, '', $req_uri); - $req_uri = str_replace($home_path, '', $req_uri); - $req_uri = trim($req_uri, '/'); - $pathinfo = trim($pathinfo, '/'); - - // The requested permalink is in $pathinfo for path info requests and - // $req_uri for other requests. - if (! empty($pathinfo) && ($wp_rewrite->index != $pathinfo)) { - $request = $pathinfo; - } else { - $request = $req_uri; - } - - // Look for matches. - $request_match = $request; - foreach ($rewrite as $match => $query) { - // If the requesting file is the anchor of the match, prepend it - // to the path info. - if ((! empty($req_uri)) && (strpos($match, $req_uri) === 0) && ($req_uri != $request)) { - $request_match = $req_uri . '/' . $request; - } - - if (preg_match("!^$match!", $request_match, $matches)) { - // Got a match. - // Trim the query of everything up to the '?'. - $query = preg_replace("!^.+\?!", '', $query); - - // Substitute the substring matches into the query. - eval("\$query = \"$query\";"); + $pathinfo = $_SERVER['PATH_INFO']; + $pathinfo_array = explode('?', $pathinfo); + $pathinfo = $pathinfo_array[0]; + $req_uri = $_SERVER['REQUEST_URI']; + $req_uri_array = explode('?', $req_uri); + $req_uri = $req_uri_array[0]; + $self = $_SERVER['PHP_SELF']; + $home_path = parse_url(get_settings('home')); + $home_path = $home_path['path']; + + // Trim path info from the end and the leading home path from the + // front. For path info requests, this leaves us with the requesting + // filename, if any. For 404 requests, this leaves us with the + // requested permalink. + $req_uri = str_replace($pathinfo, '', $req_uri); + $req_uri = str_replace($home_path, '', $req_uri); + $req_uri = trim($req_uri, '/'); + $pathinfo = trim($pathinfo, '/'); + $self = str_replace($home_path, '', $self); + $self = trim($self, '/'); + + // The requested permalink is in $pathinfo for path info requests and + // $req_uri for other requests. + if (! empty($pathinfo) && ($wp_rewrite->index != $pathinfo)) { + $request = $pathinfo; + } else { + $request = $req_uri; + } - // Parse the query. - parse_str($query, $query_vars); + // Look for matches. + $request_match = $request; + foreach ($rewrite as $match => $query) { + // If the requesting file is the anchor of the match, prepend it + // to the path info. + if ((! empty($req_uri)) && (strpos($match, $req_uri) === 0) && ($req_uri != $request)) { + $request_match = $req_uri . '/' . $request; + } - // If we're processing a 404 request, clear the error var - // since we found something. - if (isset($_GET['error'])) { - unset($_GET['error']); - } + if (preg_match("!^$match!", $request_match, $matches)) { + // Got a match. + // Trim the query of everything up to the '?'. + $query = preg_replace("!^.+\?!", '', $query); - if (isset($error)) { - unset($error); - } + // Substitute the substring matches into the query. + eval("\$query = \"$query\";"); - break; - } - } + // Parse the query. + parse_str($query, $query_vars); - // If req_uri is empty, the home page was requested. Unset error. - if ( empty($req_uri) ) { + // If we're processing a 404 request, clear the error var + // since we found something. if (isset($_GET['error'])) { unset($_GET['error']); } @@ -1498,6 +1481,19 @@ class WP { if (isset($error)) { unset($error); } + + break; + } + } + + // If req_uri is empty or if it is a request for ourself, unset error. + if ( empty($request) || $req_uri == $self ) { + if (isset($_GET['error'])) { + unset($_GET['error']); + } + + if (isset($error)) { + unset($error); } } } |
