[wp-trac] [WordPress Trac] #19412: Changeset 18995 can lead to Notice: Undefined index: wp_the_query

WordPress Trac wp-trac at lists.automattic.com
Wed Dec 7 03:30:38 UTC 2011


#19412: Changeset 18995 can lead to Notice: Undefined index: wp_the_query
-----------------------------+------------------------------
 Reporter:  bobbingwide      |       Owner:
     Type:  defect (bug)     |      Status:  reopened
 Priority:  normal           |   Milestone:  Awaiting Review
Component:  Query            |     Version:  3.3
 Severity:  normal           |  Resolution:
 Keywords:  has-patch close  |
-----------------------------+------------------------------

Comment (by nacin):

 Replying to bobbingwide:
 > And it still doesn't explain why PHP masked the Notice when the & was
 present.

 Because it creates a reference between variables, rather than any sort of
 assignment. So you can say `$a =& $b;` without `$b` being set, because
 then `$b` references `$a` (or vice versa). However, objects are
 automatically passed by reference, which means that if $b is an object,
 then `$a = $b;` makes them both reference the same object.

 Where the notice kicks in is where $wp_the_query isn't yet defined. There
 is no requirement for query_posts() to have been called — the issue is
 specifically calling a query-related function before the query is even
 initialized in wp-settings.php.

 > (You may even find problems in WordPress itself, in which case you
 should file a bug report.)

 Thank you for referring me to one of my own blog posts. :-)

 The change in wp-settings.php could also occur.

-- 
Ticket URL: <http://core.trac.wordpress.org/ticket/19412#comment:12>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software


More information about the wp-trac mailing list