Make WordPress Core

Opened 14 years ago

Closed 14 years ago

Last modified 14 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's profile dave1010 Owned by:
Milestone: Priority: normal
Severity: normal Version: 3.1
Component: General Keywords:
Focuses: Cc:

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
14 years ago

  • Resolution set to duplicate
  • Status changed from new to closed

#2 @nacin
14 years ago

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