Opened 14 years ago
Closed 14 years ago
#22125 closed defect (bug) (fixed)
Prevent stomping $wp_the_query by accident
| Reported by: | scribu | Owned by: | ryan |
|---|---|---|---|
| Priority: | high | Milestone: | 3.5 |
| Component: | Query | Version: | 3.5 |
| Severity: | blocker | Keywords: | has-patch |
| Cc: | Focuses: |
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.
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)
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.