[wp-trac] [WordPress Trac] #29930: Polluted globals break Tests_Option_BlogOption

WordPress Trac noreply at wordpress.org
Sat Oct 11 17:41:07 UTC 2014


#29930: Polluted globals break Tests_Option_BlogOption
--------------------------------+-----------------------
 Reporter:  jeremyfelt          |      Owner:
     Type:  defect (bug)        |     Status:  new
 Priority:  normal              |  Milestone:  4.1
Component:  Networks and Sites  |    Version:
 Severity:  normal              |   Keywords:  has-patch
  Focuses:  multisite           |
--------------------------------+-----------------------
 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

--
Ticket URL: <https://core.trac.wordpress.org/ticket/29930>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list