[wp-trac] [WordPress Trac] #15770: WP_Query queries for non-existant pages result in is_404() = false & is_page() = true
WordPress Trac
wp-trac at lists.automattic.com
Sat Dec 11 06:26:25 UTC 2010
#15770: WP_Query queries for non-existant pages result in is_404() = false &
is_page() = true
--------------------------+-------------------------------------------------
Reporter: dd32 | Owner:
Type: defect (bug) | Status: new
Priority: normal | Milestone: Awaiting Review
Component: Query | Version: 2.9
Severity: normal | Keywords:
--------------------------+-------------------------------------------------
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.
--
Ticket URL: <http://core.trac.wordpress.org/ticket/15770>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software
More information about the wp-trac
mailing list