Remove global regs that can poison query objects. fixes #9854

git-svn-id: http://svn.automattic.com/wordpress/trunk@11406 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
ryan 2009-05-20 16:05:23 +00:00
parent e5f7b9d7fc
commit 458a0cf306
2 changed files with 7 additions and 7 deletions

View File

@ -414,10 +414,10 @@ class WP {
$GLOBALS[$key] = $value; $GLOBALS[$key] = $value;
} }
$GLOBALS['query_string'] = & $this->query_string; $GLOBALS['query_string'] = $this->query_string;
$GLOBALS['posts'] = & $wp_query->posts; $GLOBALS['posts'] = & $wp_query->posts;
$GLOBALS['post'] = & $wp_query->post; $GLOBALS['post'] = $wp_query->post;
$GLOBALS['request'] = & $wp_query->request; $GLOBALS['request'] = $wp_query->request;
if ( is_single() || is_page() ) { if ( is_single() || is_page() ) {
$GLOBALS['more'] = 1; $GLOBALS['more'] = 1;

View File

@ -73,8 +73,7 @@ function &query_posts($query) {
* @uses $wp_query * @uses $wp_query
*/ */
function wp_reset_query() { function wp_reset_query() {
foreach ( array('id', 'authordata', 'day', 'currentmonth', 'page', 'pages', 'multipage', 'more', 'numpages', 'post', 'wp_query') as $var ) unset($GLOBALS['wp_query']);
unset($GLOBALS[$var]);
$GLOBALS['wp_query'] =& $GLOBALS['wp_the_query']; $GLOBALS['wp_query'] =& $GLOBALS['wp_the_query'];
global $wp_query; global $wp_query;
if ( !empty($wp_query->post) ) { if ( !empty($wp_query->post) ) {
@ -2375,12 +2374,10 @@ class WP_Query {
* @uses do_action_ref_array() Calls 'loop_start' if loop has just started * @uses do_action_ref_array() Calls 'loop_start' if loop has just started
*/ */
function the_post() { function the_post() {
unset($GLOBALS['post']); // Break the ref
global $post; global $post;
$this->in_the_loop = true; $this->in_the_loop = true;
$post = $this->next_post(); $post = $this->next_post();
setup_postdata($post); setup_postdata($post);
do_action('the_post', $post);
if ( $this->current_post == 0 ) // loop has just started if ( $this->current_post == 0 ) // loop has just started
do_action_ref_array('loop_start', array(&$this)); do_action_ref_array('loop_start', array(&$this));
@ -2649,11 +2646,14 @@ function wp_old_slug_redirect () {
* @since 1.5.0 * @since 1.5.0
* *
* @param object $post Post data. * @param object $post Post data.
* @uses do_action_ref_array() Calls 'the_post'
* @return bool True when finished. * @return bool True when finished.
*/ */
function setup_postdata($post) { function setup_postdata($post) {
global $id, $authordata, $day, $currentmonth, $page, $pages, $multipage, $more, $numpages; global $id, $authordata, $day, $currentmonth, $page, $pages, $multipage, $more, $numpages;
do_action_ref_array('the_post', array(&$post));
$id = (int) $post->ID; $id = (int) $post->ID;
$authordata = get_userdata($post->post_author); $authordata = get_userdata($post->post_author);