[wp-trac] [WordPress Trac] #19412: Changeset 18995 can lead to Notice: Undefined index: wp_the_query
WordPress Trac
wp-trac at lists.automattic.com
Fri Dec 2 17:57:59 UTC 2011
#19412: Changeset 18995 can lead to Notice: Undefined index: wp_the_query
--------------------------+------------------------------
Reporter: bobbingwide | Owner:
Type: defect (bug) | Status: new
Priority: normal | Milestone: Awaiting Review
Component: Query | Version: 3.3
Severity: normal | Resolution:
Keywords: has-patch |
--------------------------+------------------------------
Description changed by ryan:
Old description:
> In changeset 18995 there were two changes to query.php
> The comment "new does not require by reference" applies to the first but
> not the second change.
>
> Should the assignment by reference in wp_reset_query have been removed?
>
> The reported problem is:
> http://wordpress.org/support/topic/plugin-wordpress-seo-by-yoast-notice-
> undefined-index-wp_the_query?replies=2#post-2477593
>
> I had the same problem and questioned the suggested fix.
> What I don't understand is why there is no Notice: message for the
> original code.
>
> Try running this code.
> {{{
> <?php
> error_reporting( E_ALL );
> @ini_set('display_errors',1);
>
> function bad() {
> print_r( __FUNCTION__ );
> echo "\n";
>
> $GLOBALS = array( 'wp_query' => 'set' );
> print_r( $GLOBALS );
> unset($GLOBALS['wp_query']);
> $GLOBALS['wp_query'] = $GLOBALS['wp_the_query'];
> print_r( $GLOBALS );
> $GLOBALS['wp_query'] =& $GLOBALS['wp_the_query'];
> print_r( $GLOBALS );
> }
>
> function good() {
> print_r( __FUNCTION__ );
> echo "\n";
> $GLOBALS = array( 'wp_query' => 'set' );
> print_r( $GLOBALS );
> unset($GLOBALS['wp_query']);
> $GLOBALS['wp_query'] =& $GLOBALS['wp_the_query'];
> print_r( $GLOBALS );
> $GLOBALS['wp_query'] = $GLOBALS['wp_the_query'];
> print_r( $GLOBALS );
> }
>
> good();
> bad();
> }}}
New description:
In changeset r18995 there were two changes to query.php
The comment "new does not require by reference" applies to the first but
not the second change.
Should the assignment by reference in wp_reset_query have been removed?
The reported problem is:
http://wordpress.org/support/topic/plugin-wordpress-seo-by-yoast-notice-
undefined-index-wp_the_query?replies=2#post-2477593
I had the same problem and questioned the suggested fix.
What I don't understand is why there is no Notice: message for the
original code.
Try running this code.
{{{
<?php
error_reporting( E_ALL );
@ini_set('display_errors',1);
function bad() {
print_r( __FUNCTION__ );
echo "\n";
$GLOBALS = array( 'wp_query' => 'set' );
print_r( $GLOBALS );
unset($GLOBALS['wp_query']);
$GLOBALS['wp_query'] = $GLOBALS['wp_the_query'];
print_r( $GLOBALS );
$GLOBALS['wp_query'] =& $GLOBALS['wp_the_query'];
print_r( $GLOBALS );
}
function good() {
print_r( __FUNCTION__ );
echo "\n";
$GLOBALS = array( 'wp_query' => 'set' );
print_r( $GLOBALS );
unset($GLOBALS['wp_query']);
$GLOBALS['wp_query'] =& $GLOBALS['wp_the_query'];
print_r( $GLOBALS );
$GLOBALS['wp_query'] = $GLOBALS['wp_the_query'];
print_r( $GLOBALS );
}
good();
bad();
}}}
--
--
Ticket URL: <http://core.trac.wordpress.org/ticket/19412#comment:3>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software
More information about the wp-trac
mailing list