From 41b9b946162411132c85b0dc62abb86e7ed67729 Mon Sep 17 00:00:00 2001 From: Ryan Boren Date: Fri, 16 Sep 2005 03:16:12 +0000 Subject: [PATCH] Clear all other query flags if we have a 404. fixes #1413 git-svn-id: https://develop.svn.wordpress.org/trunk@2885 602fd350-edb4-49c9-b593-d223f7449a82 --- wp-includes/classes.php | 27 ++++++++++++++++++++------- 1 file changed, 20 insertions(+), 7 deletions(-) diff --git a/wp-includes/classes.php b/wp-includes/classes.php index 321946282d..ff1fb6acfc 100644 --- a/wp-includes/classes.php +++ b/wp-includes/classes.php @@ -30,7 +30,7 @@ class WP_Query { var $is_comments_popup = false; var $is_admin = false; - function init () { + function init_query_flags() { $this->is_single = false; $this->is_page = false; $this->is_archive = false; @@ -48,7 +48,9 @@ class WP_Query { $this->is_404 = false; $this->is_paged = false; $this->is_admin = false; - + } + + function init () { unset($this->posts); unset($this->query); unset($this->query_vars); @@ -57,6 +59,8 @@ class WP_Query { $this->post_count = 0; $this->current_post = -1; $this->in_the_loop = false; + + $this->init_query_flags(); } // Reparse the query vars. @@ -73,6 +77,14 @@ class WP_Query { $this->query_vars = $qv; } + if ('404' == $qv['error']) { + $this->is_404 = true; + if ( !empty($query) ) { + do_action('parse_query', array(&$this)); + } + return; + } + $qv['m'] = (int) $qv['m']; $qv['p'] = (int) $qv['p']; @@ -182,10 +194,6 @@ class WP_Query { $this->is_trackback = true; } - if ('404' == $qv['error']) { - $this->is_404 = true; - } - if ('' != $qv['paged']) { $this->is_paged = true; } @@ -207,6 +215,11 @@ class WP_Query { } } + function set_404() { + $this->init_query_flags(); + $this->is_404 = true; + } + function get($query_var) { if (isset($this->query_vars[$query_var])) { return $this->query_vars[$query_var]; @@ -1518,7 +1531,7 @@ class WP { if ( (0 == count($wp_query->posts)) && !is_404() && !is_search() && ( $this->did_permalink || (!empty($_SERVER['QUERY_STRING']) && (false === strpos($_SERVER['REQUEST_URI'], '?'))) ) ) { - $wp_query->is_404 = true; + $wp_query->set_404(); status_header( 404 ); } else { status_header( 200 );