Make WordPress Core

Opened 13 years ago

Closed 13 years ago

#26867 closed defect (bug) (fixed)

Explicitly globalize some missing query globals in wp-settings.php

Reported by: nbachiyski Owned by: nbachiyski
Priority: normal Milestone: 3.9
Component: Unit Tests Version:
Severity: normal Keywords: has-patch
Cc: Focuses:

Description

When WordPress is loaded in a function (e.g. unit tests) the variables initialized at the top level aren't globals, but we expect them to be.

For example, if in a unit test there is no way to access $wp_query, either directly or via get_query_var() before some other part of the code has initialized it.

This happens especially when we are testing a plugin and it uses $wp_query in its initialization routine.

Attachments (2)

globalize-query-vars.diff​ (753 bytes ) - added by nbachiyski 13 years ago.
globalize-wp.diff​ (371 bytes ) - added by xknown 13 years ago.

Download all attachments as: .zip

Change History (6)

#1 @nacin
13 years ago

  • Milestone Awaiting Review → 3.9

Looks good.

#2 @nbachiyski
13 years ago

  • Owner set to nbachiyski
  • Resolution → fixed
  • Status new → closed

In 26996:

Explicitly globalize some missing query globals in wp-settings.php

When WordPress is loaded in a function (e.g. unit tests) the variables initialized at the top level aren't globals, but we expect them to be.

Fixes #26867

#3 @xknown
13 years ago

  • Resolution fixed
  • Status closed → reopened

The $wp->init() call in line 334 (wp-settings.php) should be transformed to $GLOBALS['wp']->init(). Otherwise unit tests that don't call global $wp; on their config file fail with a PHP fatal error due to the fact that $wp isn't defined.

#4 @nbachiyski
13 years ago

  • Resolution → fixed
  • Status reopened → closed

In 26997:

Excplitcly globalized call to $wp later in wp-settings.php

Props xknown, fixes #26867.

Note: See TracTickets for help on using tickets.