WP_Query's init() and init_query_flags() do not do thorough resets
|Reported by:||coffee2code||Owned by:|
Despite WP_Query's init() documented claim that it "initiates object properties and sets default values" and that init_query_flags() "resets query flags to false", both are not thorough in their tasks. This likely stems from these functions not always being kept in sync with changes made to WP_Query.
For init(), the following variables, as defined in the class, are not reset:
var $request; var $post; var $comments; var $comment_count = 0; var $current_comment = -1; var $comment; var $found_posts = 0; var $max_num_pages = 0; var $max_num_comment_pages = 0;
For init_query_flags(), the following query flags, as defined in the class, are not reset:
var $is_preview = false; var $is_comments_popup = false;
The attached patch fixes those functions to unset/reset all the above object variables.
And one additional minor thing: the class variable $is_paged was not explicitly defined as a class variable unlike all the other class variables, so the patch does so.