Opened 13 years ago
Closed 13 years ago
#22125 closed defect (bug) (fixed)
Prevent stomping $wp_the_query by accident
| Reported by: |
|
Owned by: |
|
|---|---|---|---|
| Milestone: | 3.5 | Priority: | high |
| Severity: | blocker | Version: | 3.5 |
| Component: | Query | Keywords: | has-patch |
| Focuses: | Cc: |
Description
We have this in wp-settings.php:
$wp_query =& $wp_the_query;
This was necessary in PHP4, but in PHP5 it makes it easy to overwrite $wp_the_query by accident:
// tra la la, some template file $wp_query = new WP_Query( ... );
and in general it obscures the fact that $wp_the_query should remain frozen.
Attachments (2)
Change History (8)
Note: See
TracTickets for help on using
tickets.
Attached is a page template for 2012 that demonstrates that wp_reset_query does not reset to the original query when the global $wp_query is assigned a new WP_Query. This problem is fixed by 22125.diff.
The bug was introduced in [21792]. Prior to that change query_posts returned a reference which replaced the existing $wp_query reference. After the change query_posts is returning an object which replaces the referenced object.