Make WordPress Core

Opened 7 years ago

Closed 7 years ago

#29930 closed defect (bug) (fixed)

Polluted globals break Tests_Option_BlogOption

Reported by: jeremyfelt Owned by: jeremyfelt
Milestone: 4.1 Priority: normal
Severity: normal Version:
Component: Networks and Sites Keywords: has-patch
Focuses: multisite Cc:


In current trunk, I get two failed tests related to multisite:

1) Tests_Option_BlogOption::test_from_same_site
Failed asserting that false is true.


2) Tests_Option_BlogOption::test_from_same_site_with_null_blog_id
Failed asserting that false is true.


In both cases, even though get_current_blog_id() returns 1, and _wp_switched_stack is empty, the $wpdb global is polluted with old information due to our use of _setup_host_request() when testing the multisite bootstrap. Each of these loads the entire multisite bootstrap as the requested domain. This creates an environment where the blog ID changes (to say 75), but it does not appear to be a switched environment. When the teardown tasks run, we restore_current_blog() only if we see that it's switched.

The attached past makes one final _setup_host_request() to the WP_TESTS_DOMAIN after running through all other bootstrap tests. This causes ms-settings.php to setup the global stack as if it was the initial request. Tests then pass.

Related: #27884

Attachments (1)

29930.diff (594 bytes) - added by jeremyfelt 7 years ago.

Download all attachments as: .zip

Change History (2)

7 years ago

#1 @jeremyfelt
7 years ago

  • Owner set to jeremyfelt
  • Resolution set to fixed
  • Status changed from new to closed

In 29881:

Reset multisite unit tests global stack to original host after testing bootstrap

After using _setup_host_request() to test multiple domain and path combinations, use the same to set the global stack back to a domain of WP_TESTS_DOMAIN and path of /.

Fixes #29930

Note: See TracTickets for help on using tickets.