[wp-trac] [WordPress Trac] #17245: WordPress fails to load if wp-load.php is not called from the global scope
WordPress Trac
wp-trac at lists.automattic.com
Tue Apr 26 15:18:10 UTC 2011
#17245: WordPress fails to load if wp-load.php is not called from the global scope
--------------------------+-----------------------------
Reporter: dave1010 | Owner:
Type: defect (bug) | Status: new
Priority: normal | Milestone: Awaiting Review
Component: General | Version: 3.1
Severity: normal | Keywords:
--------------------------+-----------------------------
WordPress assumes it is being loaded in the global scope. Although
including WordPress from inside a function is a strange (and probably
should be an unsupported) thing to do, PHPUnit's commandline runner does
it and there are probably other reasons someone may want to do it.
See this [http://wordpress.org/support/topic/running-wordpress-tests-with-
phpunit discussion] as an example.
To fix this, wp-settings.php needs assumed globals to be specifically
defined as globals. E.g.
{{{
// assumed global:
$wp_the_query =& new WP_Query();
// changing to implied global:
$GLOBALS['wp_the_query'] =& new WP_Query();
}}}
This shouldn't affect anything else (unless I'm missing something) and it
also makes it clearer that the variables are global.
Might a patch get applied if I were to submit one?
--
Ticket URL: <http://core.trac.wordpress.org/ticket/17245>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software
More information about the wp-trac
mailing list