Make WordPress Core

Opened 15 years ago

Closed 15 years ago

Last modified 15 years ago

#17245 closed defect (bug) (duplicate)

WordPress fails to load if wp-load.php is not called from the global scope

Reported by: dave1010 Owned by:
Priority: normal Milestone:
Component: General Version: 3.1
Severity: normal Keywords:
Cc: Focuses:

Description

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 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?

Change History (2)

#1 @solarissmoke
15 years ago

  • Resolutionduplicate
  • Status newclosed

#2 @nacin
15 years ago

  • Milestone Awaiting Review
Note: See TracTickets for help on using tickets.