WordPress.org

Make WordPress Core

Opened 5 years ago

Closed 5 years ago

#28692 closed defect (bug) (fixed)

Polluted table_prefix and switched_stack in multisite unit tests

Reported by: jeremyfelt Owned by: wonderboymusic
Milestone: 4.0 Priority: normal
Severity: normal Version:
Component: Build/Test Tools Keywords: has-patch
Focuses: multisite Cc:
PR Number:

Description

At present, and seemingly since [27511], there are many test failures in multisite around various queries. Through these failures, I was seeing several Cannot use object of type WP_Error as array messages appear because the tests were trying to use database tables that didn't exist due to a polluted $_wp_switched_stack that still thought it was on site 67 after a tear down.

As of [28910], this gets even crazier and pollutes $table_prefix so that we end up with queries for wptests_66_66_66_67_67_67_68_terms, etc...

Attachments (2)

28692.diff (965 bytes) - added by jeremyfelt 5 years ago.
28692.2.diff (1001 bytes) - added by jeremyfelt 5 years ago.

Download all attachments as: .zip

Change History (6)

@jeremyfelt
5 years ago

#1 @jeremyfelt
5 years ago

28692.diff loops through restore_current_blog() on test tear down until we are back to the base site. It also resets the global $table_prefix when testing multisite's bootstrap, as we include ms-settings.php repeatedly, which relies on this to be pretty clean.

@jeremyfelt
5 years ago

#3 @jeremyfelt
5 years ago

28692.2.diff wraps ms_is_switched() with an is_multisite() check so that our regular unit tests aren't completely broken due to a non-existent function.

#4 @wonderboymusic
5 years ago

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

In 28943:

Avoid polluted $table_prefix and $_wp_switched_stack in multisite unit tests.
Add WP_TESTS_TABLE_PREFIX in bootstrap.php to ensure the original value for $table_prefix is always available.

Props jeremyfelt.
Fixes #28692.

Note: See TracTickets for help on using tickets.