diff --git a/src/wp-admin/admin.php b/src/wp-admin/admin.php index d3e58d2549..184d5c2731 100644 --- a/src/wp-admin/admin.php +++ b/src/wp-admin/admin.php @@ -84,7 +84,7 @@ require_once(ABSPATH . 'wp-admin/includes/admin.php'); auth_redirect(); // Schedule trash collection -if ( !wp_next_scheduled('wp_scheduled_delete') && !defined('WP_INSTALLING') ) +if ( ! wp_next_scheduled( 'wp_scheduled_delete' ) && ! wp_installing() ) wp_schedule_event(time(), 'daily', 'wp_scheduled_delete'); set_screen_options(); diff --git a/src/wp-admin/includes/class-wp-upgrader.php b/src/wp-admin/includes/class-wp-upgrader.php index 5b005ec30c..3ca66b8908 100644 --- a/src/wp-admin/includes/class-wp-upgrader.php +++ b/src/wp-admin/includes/class-wp-upgrader.php @@ -2604,7 +2604,7 @@ class WP_Automatic_Updater { if ( defined( 'DISALLOW_FILE_MODS' ) && DISALLOW_FILE_MODS ) return true; - if ( defined( 'WP_INSTALLING' ) ) + if ( wp_installing() ) return true; // More fine grained control can be done through the WP_AUTO_UPDATE_CORE constant and filters. diff --git a/src/wp-admin/includes/file.php b/src/wp-admin/includes/file.php index a11bc95851..6fa47806db 100644 --- a/src/wp-admin/includes/file.php +++ b/src/wp-admin/includes/file.php @@ -1081,7 +1081,7 @@ function request_filesystem_credentials($form_post, $type = '', $error = false, $stored_credentials['hostname'] .= ':' . $stored_credentials['port']; unset($stored_credentials['password'], $stored_credentials['port'], $stored_credentials['private_key'], $stored_credentials['public_key']); - if ( ! defined( 'WP_INSTALLING' ) ) { + if ( ! wp_installing() ) { update_option( 'ftp_credentials', $stored_credentials ); } return $credentials; diff --git a/src/wp-admin/includes/misc.php b/src/wp-admin/includes/misc.php index e2cf976d28..776f04c968 100644 --- a/src/wp-admin/includes/misc.php +++ b/src/wp-admin/includes/misc.php @@ -261,7 +261,7 @@ function update_recently_edited( $file ) { * @param string $value */ function update_home_siteurl( $old_value, $value ) { - if ( defined( "WP_INSTALLING" ) ) + if ( wp_installing() ) return; if ( is_multisite() && ms_is_switched() ) { diff --git a/src/wp-admin/includes/translation-install.php b/src/wp-admin/includes/translation-install.php index 8e1b827c47..2056838f00 100644 --- a/src/wp-admin/includes/translation-install.php +++ b/src/wp-admin/includes/translation-install.php @@ -94,7 +94,7 @@ function translations_api( $type, $args = null ) { * in an error, an empty array will be returned. */ function wp_get_available_translations() { - if ( ! defined( 'WP_INSTALLING' ) && false !== ( $translations = get_site_transient( 'available_translations' ) ) ) { + if ( ! wp_installing() && false !== ( $translations = get_site_transient( 'available_translations' ) ) ) { return $translations; } diff --git a/src/wp-includes/functions.php b/src/wp-includes/functions.php index a643d7ccb3..b6158ed261 100644 --- a/src/wp-includes/functions.php +++ b/src/wp-includes/functions.php @@ -1259,6 +1259,37 @@ function do_robots() { echo apply_filters( 'robots_txt', $output, $public ); } +/** + * Check or set whether WordPress is in "installation" mode. + * + * If the `WP_INSTALLING` constant is defined during the bootstrap, `wp_installing()` will default to `true`. + * + * @since 4.4.0 + * + * @staticvar bool $installing + * + * @param bool $is_installing Optional. True to set WP into Installing mode, false to turn Installing mode off. + * Omit this parameter if you only want to fetch the current status. + * @return bool True if WP is installing, otherwise false. When a `$is_installing` is passed, the function will + * report whether WP was in installing mode prior to the change to `$is_installing`. + */ +function wp_installing( $is_installing = null ) { + static $installing = null; + + // Support for the `WP_INSTALLING` constant, defined before WP is loaded. + if ( is_null( $installing ) ) { + $installing = defined( 'WP_INSTALLING' ) && WP_INSTALLING; + } + + if ( ! is_null( $is_installing ) ) { + $old_installing = $installing; + $installing = $is_installing; + return (bool) $old_installing; + } + + return (bool) $installing; +} + /** * Test whether blog is already installed. * @@ -1285,7 +1316,7 @@ function is_blog_installed() { return true; $suppress = $wpdb->suppress_errors(); - if ( ! defined( 'WP_INSTALLING' ) ) { + if ( ! wp_installing() ) { $alloptions = wp_load_alloptions(); } // If siteurl is not set to autoload, check it specifically @@ -3337,7 +3368,7 @@ function dead_db() { } // If installing or in the admin, provide the verbose message. - if ( defined('WP_INSTALLING') || defined('WP_ADMIN') ) + if ( wp_installing() || defined( 'WP_ADMIN' ) ) wp_die($wpdb->error); // Otherwise, be terse. diff --git a/src/wp-includes/l10n.php b/src/wp-includes/l10n.php index b30fa417aa..2af07f17a0 100644 --- a/src/wp-includes/l10n.php +++ b/src/wp-includes/l10n.php @@ -53,7 +53,7 @@ function get_locale() { // If multisite, check options. if ( is_multisite() ) { // Don't check blog option when installing. - if ( defined( 'WP_INSTALLING' ) || ( false === $ms_locale = get_option( 'WPLANG' ) ) ) { + if ( wp_installing() || ( false === $ms_locale = get_option( 'WPLANG' ) ) ) { $ms_locale = get_network_option( 'WPLANG' ); } @@ -635,7 +635,7 @@ function load_default_textdomain( $locale = null ) { return $return; } - if ( is_admin() || defined( 'WP_INSTALLING' ) || ( defined( 'WP_REPAIRING' ) && WP_REPAIRING ) ) { + if ( is_admin() || wp_installing() || ( defined( 'WP_REPAIRING' ) && WP_REPAIRING ) ) { load_textdomain( 'default', WP_LANG_DIR . "/admin-$locale.mo" ); } diff --git a/src/wp-includes/load.php b/src/wp-includes/load.php index 560511a953..90db8290db 100644 --- a/src/wp-includes/load.php +++ b/src/wp-includes/load.php @@ -165,7 +165,7 @@ function wp_favicon_request() { * @global int $upgrading the unix timestamp marking when upgrading WordPress began. */ function wp_maintenance() { - if ( !file_exists( ABSPATH . '.maintenance' ) || defined( 'WP_INSTALLING' ) ) + if ( ! file_exists( ABSPATH . '.maintenance' ) || wp_installing() ) return; global $upgrading; @@ -475,12 +475,12 @@ function wp_start_object_cache() { */ function wp_not_installed() { if ( is_multisite() ) { - if ( ! is_blog_installed() && ! defined( 'WP_INSTALLING' ) ) { + if ( ! is_blog_installed() && ! wp_installing() ) { nocache_headers(); wp_die( __( 'The site you have requested is not installed properly. Please contact the system administrator.' ) ); } - } elseif ( ! is_blog_installed() && ! defined( 'WP_INSTALLING' ) ) { + } elseif ( ! is_blog_installed() && ! wp_installing() ) { nocache_headers(); require( ABSPATH . WPINC . '/kses.php' ); @@ -539,7 +539,7 @@ function wp_get_mu_plugins() { function wp_get_active_and_valid_plugins() { $plugins = array(); $active_plugins = (array) get_option( 'active_plugins', array() ); - if ( empty( $active_plugins ) || defined( 'WP_INSTALLING' ) ) + if ( empty( $active_plugins ) || wp_installing() ) return $plugins; $network_plugins = is_multisite() ? wp_get_active_network_plugins() : false; diff --git a/src/wp-includes/ms-functions.php b/src/wp-includes/ms-functions.php index 2aeda64fdf..ae5a242afa 100644 --- a/src/wp-includes/ms-functions.php +++ b/src/wp-includes/ms-functions.php @@ -1116,8 +1116,9 @@ function wpmu_create_blog( $domain, $path, $title, $user_id, $meta = array(), $s if ( domain_exists($domain, $path, $site_id) ) return new WP_Error( 'blog_taken', __( 'Sorry, that site already exists!' ) ); - if ( !defined('WP_INSTALLING') ) - define( 'WP_INSTALLING', true ); + if ( ! wp_installing() ) { + wp_installing( true ); + } if ( ! $blog_id = insert_blog($domain, $path, $site_id) ) return new WP_Error('insert_blog', __('Could not create site.')); @@ -2172,7 +2173,7 @@ function wp_schedule_update_network_counts() { if ( !is_main_site() ) return; - if ( !wp_next_scheduled('update_network_counts') && !defined('WP_INSTALLING') ) + if ( ! wp_next_scheduled('update_network_counts') && ! wp_installing() ) wp_schedule_event(time(), 'twicedaily', 'update_network_counts'); } diff --git a/src/wp-includes/ms-settings.php b/src/wp-includes/ms-settings.php index 861ee14abf..a490c22248 100644 --- a/src/wp-includes/ms-settings.php +++ b/src/wp-includes/ms-settings.php @@ -136,7 +136,7 @@ if ( !isset( $current_site ) || !isset( $current_blog ) ) { } // @todo Investigate when exactly this can occur. - if ( empty( $current_blog ) && defined( 'WP_INSTALLING' ) ) { + if ( empty( $current_blog ) && wp_installing() ) { $current_blog = new stdClass; $current_blog->blog_id = $blog_id = 1; } diff --git a/src/wp-includes/option.php b/src/wp-includes/option.php index 2931c37fd1..701e485cf9 100644 --- a/src/wp-includes/option.php +++ b/src/wp-includes/option.php @@ -53,7 +53,7 @@ function get_option( $option, $default = false ) { if ( defined( 'WP_SETUP_CONFIG' ) ) return false; - if ( ! defined( 'WP_INSTALLING' ) ) { + if ( ! wp_installing() ) { // prevent non-existent options from triggering multiple queries $notoptions = wp_cache_get( 'notoptions', 'options' ); if ( isset( $notoptions[ $option ] ) ) { @@ -171,7 +171,7 @@ function form_option( $option ) { function wp_load_alloptions() { global $wpdb; - if ( !defined( 'WP_INSTALLING' ) || !is_multisite() ) + if ( ! wp_installing() || ! is_multisite() ) $alloptions = wp_cache_get( 'alloptions', 'options' ); else $alloptions = false; @@ -185,7 +185,7 @@ function wp_load_alloptions() { foreach ( (array) $alloptions_db as $o ) { $alloptions[$o->option_name] = $o->option_value; } - if ( !defined( 'WP_INSTALLING' ) || !is_multisite() ) + if ( ! wp_installing() || ! is_multisite() ) wp_cache_add( 'alloptions', $alloptions, 'options' ); } @@ -204,7 +204,7 @@ function wp_load_alloptions() { function wp_load_core_site_options( $site_id = null ) { global $wpdb; - if ( !is_multisite() || wp_using_ext_object_cache() || defined( 'WP_INSTALLING' ) ) + if ( ! is_multisite() || wp_using_ext_object_cache() || wp_installing() ) return; if ( empty($site_id) ) @@ -332,7 +332,7 @@ function update_option( $option, $value, $autoload = null ) { wp_cache_set( 'notoptions', $notoptions, 'options' ); } - if ( ! defined( 'WP_INSTALLING' ) ) { + if ( ! wp_installing() ) { $alloptions = wp_load_alloptions(); if ( isset( $alloptions[$option] ) ) { $alloptions[ $option ] = $serialized_value; @@ -433,7 +433,7 @@ function add_option( $option, $value = '', $deprecated = '', $autoload = 'yes' ) if ( ! $result ) return false; - if ( ! defined( 'WP_INSTALLING' ) ) { + if ( ! wp_installing() ) { if ( 'yes' == $autoload ) { $alloptions = wp_load_alloptions(); $alloptions[ $option ] = $serialized_value; @@ -509,7 +509,7 @@ function delete_option( $option ) { do_action( 'delete_option', $option ); $result = $wpdb->delete( $wpdb->options, array( 'option_name' => $option ) ); - if ( ! defined( 'WP_INSTALLING' ) ) { + if ( ! wp_installing() ) { if ( 'yes' == $row->autoload ) { $alloptions = wp_load_alloptions(); if ( is_array( $alloptions ) && isset( $alloptions[$option] ) ) { @@ -629,7 +629,7 @@ function get_transient( $transient ) { $value = wp_cache_get( $transient, 'transient' ); } else { $transient_option = '_transient_' . $transient; - if ( ! defined( 'WP_INSTALLING' ) ) { + if ( ! wp_installing() ) { // If option is not in alloptions, it is not autoloaded and thus has a timeout $alloptions = wp_load_alloptions(); if ( !isset( $alloptions[$transient_option] ) ) { diff --git a/src/wp-includes/script-loader.php b/src/wp-includes/script-loader.php index 1b28da52f1..a812ffe248 100644 --- a/src/wp-includes/script-loader.php +++ b/src/wp-includes/script-loader.php @@ -829,7 +829,7 @@ function wp_just_in_time_script_localization() { function wp_style_loader_src( $src, $handle ) { global $_wp_admin_css_colors; - if ( defined('WP_INSTALLING') ) + if ( wp_installing() ) return preg_replace( '#^wp-admin/#', './', $src ); if ( 'colors' == $handle ) { diff --git a/src/wp-includes/theme.php b/src/wp-includes/theme.php index 906da5176f..e1a0334ed9 100644 --- a/src/wp-includes/theme.php +++ b/src/wp-includes/theme.php @@ -771,7 +771,7 @@ function validate_current_theme() { * * @param bool true Validation flag to check the current theme. */ - if ( defined('WP_INSTALLING') || ! apply_filters( 'validate_current_theme', true ) ) + if ( wp_installing() || ! apply_filters( 'validate_current_theme', true ) ) return true; if ( get_template() != WP_DEFAULT_THEME && !file_exists(get_template_directory() . '/index.php') ) { diff --git a/src/wp-includes/update.php b/src/wp-includes/update.php index c39322ee46..1def316be0 100644 --- a/src/wp-includes/update.php +++ b/src/wp-includes/update.php @@ -22,7 +22,7 @@ * @param bool $force_check Whether to bypass the transient cache and force a fresh update check. Defaults to false, true if $extra_stats is set. */ function wp_version_check( $extra_stats = array(), $force_check = false ) { - if ( defined( 'WP_INSTALLING' ) ) { + if ( wp_installing() ) { return; } @@ -187,7 +187,7 @@ function wp_version_check( $extra_stats = array(), $force_check = false ) { * @param array $extra_stats Extra statistics to report to the WordPress.org API. */ function wp_update_plugins( $extra_stats = array() ) { - if ( defined( 'WP_INSTALLING' ) ) { + if ( wp_installing() ) { return; } @@ -344,7 +344,7 @@ function wp_update_plugins( $extra_stats = array() ) { * @param array $extra_stats Extra statistics to report to the WordPress.org API. */ function wp_update_themes( $extra_stats = array() ) { - if ( defined( 'WP_INSTALLING' ) ) { + if ( wp_installing() ) { return; } global $wp_version; @@ -636,16 +636,16 @@ function _maybe_update_themes() { * @since 3.1.0 */ function wp_schedule_update_checks() { - if ( !wp_next_scheduled('wp_version_check') && !defined('WP_INSTALLING') ) + if ( ! wp_next_scheduled( 'wp_version_check' ) && ! wp_installing() ) wp_schedule_event(time(), 'twicedaily', 'wp_version_check'); - if ( !wp_next_scheduled('wp_update_plugins') && !defined('WP_INSTALLING') ) + if ( ! wp_next_scheduled( 'wp_update_plugins' ) && ! wp_installing() ) wp_schedule_event(time(), 'twicedaily', 'wp_update_plugins'); - if ( !wp_next_scheduled('wp_update_themes') && !defined('WP_INSTALLING') ) + if ( ! wp_next_scheduled( 'wp_update_themes' ) && ! wp_installing() ) wp_schedule_event(time(), 'twicedaily', 'wp_update_themes'); - if ( ! wp_next_scheduled( 'wp_maybe_auto_update' ) && ! defined( 'WP_INSTALLING' ) ) { + if ( ! wp_next_scheduled( 'wp_maybe_auto_update' ) && ! wp_installing() ) { // Schedule auto updates for 7 a.m. and 7 p.m. in the timezone of the site. $next = strtotime( 'today 7am' ); $now = time(); diff --git a/src/wp-settings.php b/src/wp-settings.php index 993a12096e..9a3afd840f 100644 --- a/src/wp-settings.php +++ b/src/wp-settings.php @@ -321,7 +321,7 @@ require_once( ABSPATH . WPINC . '/locale.php' ); $GLOBALS['wp_locale'] = new WP_Locale(); // Load the functions for the active theme, for both parent and child theme if applicable. -if ( ! defined( 'WP_INSTALLING' ) || 'wp-activate.php' === $pagenow ) { +if ( ! wp_installing() || 'wp-activate.php' === $pagenow ) { if ( TEMPLATEPATH !== STYLESHEETPATH && file_exists( STYLESHEETPATH . '/functions.php' ) ) include( STYLESHEETPATH . '/functions.php' ); if ( file_exists( TEMPLATEPATH . '/functions.php' ) ) diff --git a/tests/phpunit/includes/factory.php b/tests/phpunit/includes/factory.php index 20bad89a96..bc8ea09b7d 100644 --- a/tests/phpunit/includes/factory.php +++ b/tests/phpunit/includes/factory.php @@ -173,6 +173,10 @@ class WP_UnitTest_Factory_For_Blog extends WP_UnitTest_Factory_For_Thing { $suppress = $wpdb->suppress_errors(); $blog = wpmu_create_blog( $args['domain'], $args['path'], $args['title'], $user_id, $meta, $args['site_id'] ); $wpdb->suppress_errors( $suppress ); + + // Tell WP we're done installing. + wp_installing( false ); + return $blog; } diff --git a/tests/phpunit/includes/testcase.php b/tests/phpunit/includes/testcase.php index 8ced19744f..199f7eb745 100644 --- a/tests/phpunit/includes/testcase.php +++ b/tests/phpunit/includes/testcase.php @@ -14,8 +14,6 @@ class WP_UnitTestCase extends PHPUnit_Framework_TestCase { protected static $hooks_saved = array(); protected static $ignore_files; - protected $db_version; - /** * @var WP_UnitTest_Factory */ @@ -58,19 +56,6 @@ class WP_UnitTestCase extends PHPUnit_Framework_TestCase { add_filter( 'wp_die_handler', array( $this, 'get_wp_die_handler' ) ); add_filter( 'wp_mail', array( $this, 'set_wp_mail_globals' ) ); - - /* - * During multisite tests, WP_INSTALLING forces `get_option()` to miss the cache, which causes problems - * with our query-counting cache tests. As a workaround in the case of tests that require checking - * 'db_version' (such as any test that uses the Term Meta API), we filter 'pre_option_db_version' and - * avoid hitting the database. - * - * See #31130. - */ - $this->db_version = get_option( 'db_version' ); - if ( is_multisite() ) { - add_filter( 'pre_option_db_version', array( $this, 'db_version' ) ); - } } /** @@ -634,19 +619,6 @@ class WP_UnitTestCase extends PHPUnit_Framework_TestCase { } } - /** - * Return the current database version without hitting the database. - * - * This is used to bypass cache problems with some multisite tests. See #31130. - * - * @todo Don't do this anymore once #31130 is fixed. - * - * @since 4.4.0 - */ - public function db_version() { - return $this->db_version; - } - /** * Utility method that resets permalinks and flushes rewrites. * diff --git a/tests/phpunit/tests/comment/getPageOfComment.php b/tests/phpunit/tests/comment/getPageOfComment.php index 78151d24f0..a088894652 100644 --- a/tests/phpunit/tests/comment/getPageOfComment.php +++ b/tests/phpunit/tests/comment/getPageOfComment.php @@ -60,11 +60,6 @@ class Tests_Comment_GetPageOfComment extends WP_UnitTestCase { * @ticket 11334 */ public function test_subsequent_calls_should_hit_cache() { - // `get_page_of_comment()` calls `get_option()`, which is not properly cached when WP_INSTALLING. - if ( is_multisite() ) { - $this->markTestSkipped( 'Not testable in MS: wpmu_create_blog() defines WP_INSTALLING, which causes cache misses.' ); - } - global $wpdb; $p = $this->factory->post->create(); diff --git a/tests/phpunit/tests/general/archives.php b/tests/phpunit/tests/general/archives.php index 23d1131223..b70b5e3e3e 100644 --- a/tests/phpunit/tests/general/archives.php +++ b/tests/phpunit/tests/general/archives.php @@ -16,10 +16,6 @@ class Tests_General_Archives extends WP_UnitTestCase { function test_get_archives_cache() { global $wpdb; - if ( is_multisite() ) { - $this->markTestSkipped( 'Not testable in MS: wpmu_create_blog() defines WP_INSTALLING, which causes cache misses.' ); - } - $this->factory->post->create_many( 15, array( 'post_type' => 'post' ) ); wp_cache_delete( 'last_changed', 'posts' ); $this->assertFalse( wp_cache_get( 'last_changed', 'posts' ) ); @@ -112,4 +108,4 @@ class Tests_General_Archives extends WP_UnitTestCase { $this->assertEquals( $time1, wp_cache_get( 'last_changed', 'posts' ) ); $this->assertEquals( $num_queries, $wpdb->num_queries ); } -} \ No newline at end of file +} diff --git a/tests/phpunit/tests/option/transient.php b/tests/phpunit/tests/option/transient.php index 06833b6830..759a9b4f7e 100644 --- a/tests/phpunit/tests/option/transient.php +++ b/tests/phpunit/tests/option/transient.php @@ -46,10 +46,6 @@ class Tests_Option_Transient extends WP_UnitTestCase { * @ticket 22807 */ function test_transient_data_with_timeout() { - if ( is_multisite() ) { - $this->markTestSkipped( 'Not testable in MS: wpmu_create_blog() defines WP_INSTALLING.' ); - } - $key = rand_str(); $value = rand_str(); @@ -71,10 +67,6 @@ class Tests_Option_Transient extends WP_UnitTestCase { * @ticket 22807 */ function test_transient_add_timeout() { - if ( is_multisite() ) { - $this->markTestSkipped( 'Not testable in MS: wpmu_create_blog() defines WP_INSTALLING.' ); - } - $key = rand_str(); $value = rand_str(); $value2 = rand_str(); @@ -126,10 +118,6 @@ class Tests_Option_Transient extends WP_UnitTestCase { * @ticket 30380 */ function test_nonexistent_key_old_timeout() { - if ( is_multisite() ) { - $this->markTestSkipped( 'Not testable in MS: wpmu_create_blog() defines WP_INSTALLING.' ); - } - // Create a transient $key = 'test_transient'; set_transient( $key, 'test', 60 * 10 ); diff --git a/tests/phpunit/tests/option/updateOption.php b/tests/phpunit/tests/option/updateOption.php index 8409281c90..01064ca187 100644 --- a/tests/phpunit/tests/option/updateOption.php +++ b/tests/phpunit/tests/option/updateOption.php @@ -20,10 +20,6 @@ class Tests_Option_UpdateOption extends WP_UnitTestCase { * @ticket 26394 */ public function test_should_set_autoload_yes_for_nonexistent_option_when_autoload_param_is_missing() { - if ( is_multisite() ) { - $this->markTestSkipped( 'Not testable in MS: wpmu_create_blog() defines WP_INSTALLING, which causes cache misses.' ); - } - global $wpdb; $this->flush_cache(); update_option( 'test_update_option_default', 'value' ); @@ -44,10 +40,6 @@ class Tests_Option_UpdateOption extends WP_UnitTestCase { * @ticket 26394 */ public function test_should_set_autoload_yes_for_nonexistent_option_when_autoload_param_is_yes() { - if ( is_multisite() ) { - $this->markTestSkipped( 'Not testable in MS: wpmu_create_blog() defines WP_INSTALLING, which causes cache misses.' ); - } - global $wpdb; $this->flush_cache(); update_option( 'test_update_option_default', 'value', 'yes' ); @@ -68,10 +60,6 @@ class Tests_Option_UpdateOption extends WP_UnitTestCase { * @ticket 26394 */ public function test_should_set_autoload_no_for_nonexistent_option_when_autoload_param_is_no() { - if ( is_multisite() ) { - $this->markTestSkipped( 'Not testable in MS: wpmu_create_blog() defines WP_INSTALLING, which causes cache misses.' ); - } - global $wpdb; $this->flush_cache(); update_option( 'test_update_option_default', 'value', 'no' ); @@ -93,10 +81,6 @@ class Tests_Option_UpdateOption extends WP_UnitTestCase { * @ticket 26394 */ public function test_should_set_autoload_no_for_nonexistent_option_when_autoload_param_is_false() { - if ( is_multisite() ) { - $this->markTestSkipped( 'Not testable in MS: wpmu_create_blog() defines WP_INSTALLING, which causes cache misses.' ); - } - global $wpdb; $this->flush_cache(); update_option( 'test_update_option_default', 'value', false ); @@ -118,10 +102,6 @@ class Tests_Option_UpdateOption extends WP_UnitTestCase { * @group 26394 */ public function test_autoload_should_be_updated_for_existing_option_when_value_is_changed() { - if ( is_multisite() ) { - $this->markTestSkipped( 'Not testable in MS: wpmu_create_blog() defines WP_INSTALLING, which causes cache misses.' ); - } - global $wpdb; add_option( 'foo', 'bar', '', 'no' ); $updated = update_option( 'foo', 'bar2', true ); @@ -143,10 +123,6 @@ class Tests_Option_UpdateOption extends WP_UnitTestCase { * @group 26394 */ public function test_autoload_should_not_be_updated_for_existing_option_when_value_is_unchanged() { - if ( is_multisite() ) { - $this->markTestSkipped( 'Not testable in MS: wpmu_create_blog() defines WP_INSTALLING, which causes cache misses.' ); - } - global $wpdb; add_option( 'foo', 'bar', '', 'yes' ); $updated = update_option( 'foo', 'bar', false ); @@ -169,10 +145,6 @@ class Tests_Option_UpdateOption extends WP_UnitTestCase { * @group 26394 */ public function test_autoload_should_not_be_updated_for_existing_option_when_value_is_changed_but_no_value_of_autoload_is_provided() { - if ( is_multisite() ) { - $this->markTestSkipped( 'Not testable in MS: wpmu_create_blog() defines WP_INSTALLING, which causes cache misses.' ); - } - global $wpdb; add_option( 'foo', 'bar', '', 'yes' ); diff --git a/tests/phpunit/tests/post/getPostClass.php b/tests/phpunit/tests/post/getPostClass.php index 5e64e33841..8d29c405da 100644 --- a/tests/phpunit/tests/post/getPostClass.php +++ b/tests/phpunit/tests/post/getPostClass.php @@ -108,10 +108,6 @@ class Tests_Post_GetPostClass extends WP_UnitTestCase { public function test_taxonomy_classes_hit_cache() { global $wpdb; - if ( is_multisite() ) { - $this->markTestSkipped( 'Not testable in MS: wpmu_create_blog() defines WP_INSTALLING, which causes cache misses.' ); - } - register_taxonomy( 'wptests_tax', 'post' ); wp_set_post_terms( $this->post_id, array( 'foo', 'bar' ), 'wptests_tax' ); wp_set_post_terms( $this->post_id, array( 'footag', 'bartag' ), 'post_tag' ); diff --git a/tests/phpunit/tests/term/getTerms.php b/tests/phpunit/tests/term/getTerms.php index f1db1aa179..5256b823ba 100644 --- a/tests/phpunit/tests/term/getTerms.php +++ b/tests/phpunit/tests/term/getTerms.php @@ -382,10 +382,6 @@ class Tests_Term_getTerms extends WP_UnitTestCase { public function test_child_of_should_skip_query_when_specified_parent_is_not_found_in_hierarchy_cache() { global $wpdb; - if ( is_multisite() ) { - $this->markTestSkipped( 'Not testable in MS: wpmu_create_blog() defines WP_INSTALLING, which causes cache misses.' ); - } - register_taxonomy( 'wptests_tax', 'post', array( 'hierarchical' => true, ) ); $terms = $this->factory->term->create_many( 3, array( 'taxonomy' => 'wptests_tax' ) ); @@ -1327,10 +1323,6 @@ class Tests_Term_getTerms extends WP_UnitTestCase { public function test_parent_should_skip_query_when_specified_parent_is_not_found_in_hierarchy_cache() { global $wpdb; - if ( is_multisite() ) { - $this->markTestSkipped( 'Not testable in MS: wpmu_create_blog() defines WP_INSTALLING, which causes cache misses.' ); - } - register_taxonomy( 'wptests_tax', 'post', array( 'hierarchical' => true, ) ); $terms = $this->factory->term->create_many( 3, array( 'taxonomy' => 'wptests_tax' ) ); diff --git a/tests/phpunit/tests/term/wpInsertTerm.php b/tests/phpunit/tests/term/wpInsertTerm.php index 0b5077ab28..90fb4c4e27 100644 --- a/tests/phpunit/tests/term/wpInsertTerm.php +++ b/tests/phpunit/tests/term/wpInsertTerm.php @@ -468,15 +468,8 @@ class Tests_Term_WpInsertTerm extends WP_UnitTestCase { * @ticket 5809 */ public function test_wp_insert_term_duplicate_slug_different_taxonomy_before_410_schema_change() { - - // See #31130. $old_db_version = 30055; - if ( is_multisite() ) { - $_db_version = $this->db_version; - $this->db_version = $old_db_version; - } else { - update_option( 'db_version', $old_db_version ); - } + update_option( 'db_version', $old_db_version ); register_taxonomy( 'wptests_tax', 'post' ); register_taxonomy( 'wptests_tax_2', 'post' ); @@ -503,10 +496,6 @@ class Tests_Term_WpInsertTerm extends WP_UnitTestCase { $this->assertSame( 'foo-2', $new_term->slug ); $this->assertNotEquals( $new_term->term_id, $term->term_id ); - if ( is_multisite() ) { - $this->db_version = $_db_version; - } - _unregister_taxonomy( 'wptests_tax', 'post' ); } diff --git a/tests/phpunit/tests/user/capabilities.php b/tests/phpunit/tests/user/capabilities.php index 17a8e0a63c..2f58902315 100644 --- a/tests/phpunit/tests/user/capabilities.php +++ b/tests/phpunit/tests/user/capabilities.php @@ -873,6 +873,8 @@ class Tests_User_Capabilities extends WP_UnitTestCase { } function test_current_user_can_for_blog() { + global $wpdb; + $user = new WP_User( $this->factory->user->create( array( 'role' => 'administrator' ) ) ); $old_uid = get_current_user_id(); wp_set_current_user( $user->ID ); @@ -884,7 +886,9 @@ class Tests_User_Capabilities extends WP_UnitTestCase { return; } + $suppress = $wpdb->suppress_errors(); $this->assertFalse( current_user_can_for_blog( 12345, 'edit_posts' ) ); + $wpdb->suppress_errors( $suppress ); $blog_id = $this->factory->blog->create( array( 'user_id' => $user->ID ) ); $this->assertTrue( current_user_can_for_blog( $blog_id, 'edit_posts' ) );