Opened 10 years ago
Closed 10 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: |
Description
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. /srv/www/wordpress-develop/tests/phpunit/tests/option/blogOption.php:33 2) Tests_Option_BlogOption::test_from_same_site_with_null_blog_id Failed asserting that false is true. /srv/www/wordpress-develop/tests/phpunit/tests/option/blogOption.php:70
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
In 29881: