#15770 closed defect (bug) (fixed)
WP_Query queries for non-existant pages result in is_404() = false & is_page() = true
Reported by: | dd32 | Owned by: | ryan |
---|---|---|---|
Milestone: | 3.4 | Priority: | normal |
Severity: | normal | Version: | 2.9 |
Component: | Query | Keywords: | has-patch |
Focuses: | Cc: |
Description
WP_Query queries for non-existant pages result in is_404() = false & is_page() = true
For example:
$query = array('pagename' => 'this-is-a-404-page'); $query = new WP_Query($query); var_dump($query); ?> object(WP_Query)[223] public 'query_vars' => array 'pagename' => string 'this-is-a-404-page' (length=18) 'error' => string '' (length=0) 'name' => string 'this-is-a-404-page' (length=18) 'static' => string '' (length=0) 'page_id' => int 0 'post_type' => string '' (length=0) <Sniped extra empty query vars for paste length> public 'tax_query' => object(WP_Tax_Query)[111] public 'queries' => array empty public 'relation' => string 'AND' (length=3) public 'post_count' => int 0 public 'current_post' => int -1 public 'in_the_loop' => boolean false public 'comment_count' => int 0 public 'current_comment' => int -1 public 'found_posts' => int 0 public 'max_num_pages' => int 0 public 'max_num_comment_pages' => int 0 public 'is_single' => boolean false public 'is_preview' => boolean false public 'is_page' => boolean true public 'is_archive' => boolean false public 'is_date' => boolean false public 'is_year' => boolean false public 'is_month' => boolean false public 'is_day' => boolean false public 'is_time' => boolean false public 'is_author' => boolean false public 'is_category' => boolean false public 'is_tag' => boolean false public 'is_tax' => boolean false public 'is_search' => boolean false public 'is_feed' => boolean false public 'is_comment_feed' => boolean false public 'is_trackback' => boolean false public 'is_home' => boolean false public 'is_404' => boolean false public 'is_comments_popup' => boolean false public 'is_paged' => boolean false public 'is_admin' => boolean true public 'is_attachment' => boolean false public 'is_singular' => boolean true public 'is_robots' => boolean false public 'is_posts_page' => boolean false public 'is_post_type_archive' => boolean false public 'query' => array 'pagename' => string 'this-is-a-404-page' (length=18) public 'request' => string ' SELECT wp_posts.* FROM wp_posts WHERE 1=1 AND (wp_posts.ID = '0') AND wp_posts.post_type = 'page' ORDER BY wp_posts.post_date DESC ' (length=137) public 'posts' => array empty
This is not a regression, Tested in 3.0 and 2.9. To me it doesnt make sense for a instance of WP_Query to not reset the conditionals after a unsuccessful request.
This does not affect front end, as the WP Class is responsible for determining that WP_Query has returned nill results and 404'ing.
Attachments (2)
Change History (10)
#4
@
13 years ago
I mentioned to benbalter how the logic in 15770.diff could be improved a bit. Then I tried to actually improve it myself, and got fed up with the current statements in handle_404(), and ended up with 15770.2.diff.
#5
@
13 years ago
- Keywords dev-feedback needs-testing removed
Tested, and nacin's 15770.2.diff fixes the problem.
Note: See
TracTickets for help on using
tickets.
See #15771 which was caused as a result of this.