Changeset 34828
- Timestamp:
- 10/05/2015 03:05:26 PM (9 years ago)
- Location:
- trunk
- Files:
-
- 25 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-admin/admin.php
r34265 r34828 85 85 86 86 // Schedule trash collection 87 if ( ! wp_next_scheduled('wp_scheduled_delete') && !defined('WP_INSTALLING') )87 if ( ! wp_next_scheduled( 'wp_scheduled_delete' ) && ! wp_installing() ) 88 88 wp_schedule_event(time(), 'daily', 'wp_scheduled_delete'); 89 89 -
trunk/src/wp-admin/includes/class-wp-upgrader.php
r34778 r34828 2605 2605 return true; 2606 2606 2607 if ( defined( 'WP_INSTALLING') )2607 if ( wp_installing() ) 2608 2608 return true; 2609 2609 -
trunk/src/wp-admin/includes/file.php
r34658 r34828 1082 1082 1083 1083 unset($stored_credentials['password'], $stored_credentials['port'], $stored_credentials['private_key'], $stored_credentials['public_key']); 1084 if ( ! defined( 'WP_INSTALLING') ) {1084 if ( ! wp_installing() ) { 1085 1085 update_option( 'ftp_credentials', $stored_credentials ); 1086 1086 } -
trunk/src/wp-admin/includes/misc.php
r34824 r34828 262 262 */ 263 263 function update_home_siteurl( $old_value, $value ) { 264 if ( defined( "WP_INSTALLING") )264 if ( wp_installing() ) 265 265 return; 266 266 -
trunk/src/wp-admin/includes/translation-install.php
r32643 r34828 95 95 */ 96 96 function wp_get_available_translations() { 97 if ( ! defined( 'WP_INSTALLING') && false !== ( $translations = get_site_transient( 'available_translations' ) ) ) {97 if ( ! wp_installing() && false !== ( $translations = get_site_transient( 'available_translations' ) ) ) { 98 98 return $translations; 99 99 } -
trunk/src/wp-includes/functions.php
r34793 r34828 1261 1261 1262 1262 /** 1263 * Check or set whether WordPress is in "installation" mode. 1264 * 1265 * If the `WP_INSTALLING` constant is defined during the bootstrap, `wp_installing()` will default to `true`. 1266 * 1267 * @since 4.4.0 1268 * 1269 * @staticvar bool $installing 1270 * 1271 * @param bool $is_installing Optional. True to set WP into Installing mode, false to turn Installing mode off. 1272 * Omit this parameter if you only want to fetch the current status. 1273 * @return bool True if WP is installing, otherwise false. When a `$is_installing` is passed, the function will 1274 * report whether WP was in installing mode prior to the change to `$is_installing`. 1275 */ 1276 function wp_installing( $is_installing = null ) { 1277 static $installing = null; 1278 1279 // Support for the `WP_INSTALLING` constant, defined before WP is loaded. 1280 if ( is_null( $installing ) ) { 1281 $installing = defined( 'WP_INSTALLING' ) && WP_INSTALLING; 1282 } 1283 1284 if ( ! is_null( $is_installing ) ) { 1285 $old_installing = $installing; 1286 $installing = $is_installing; 1287 return (bool) $old_installing; 1288 } 1289 1290 return (bool) $installing; 1291 } 1292 1293 /** 1263 1294 * Test whether blog is already installed. 1264 1295 * … … 1286 1317 1287 1318 $suppress = $wpdb->suppress_errors(); 1288 if ( ! defined( 'WP_INSTALLING') ) {1319 if ( ! wp_installing() ) { 1289 1320 $alloptions = wp_load_alloptions(); 1290 1321 } … … 3338 3369 3339 3370 // If installing or in the admin, provide the verbose message. 3340 if ( defined('WP_INSTALLING') || defined('WP_ADMIN') )3371 if ( wp_installing() || defined( 'WP_ADMIN' ) ) 3341 3372 wp_die($wpdb->error); 3342 3373 -
trunk/src/wp-includes/l10n.php
r34781 r34828 54 54 if ( is_multisite() ) { 55 55 // Don't check blog option when installing. 56 if ( defined( 'WP_INSTALLING') || ( false === $ms_locale = get_option( 'WPLANG' ) ) ) {56 if ( wp_installing() || ( false === $ms_locale = get_option( 'WPLANG' ) ) ) { 57 57 $ms_locale = get_network_option( 'WPLANG' ); 58 58 } … … 636 636 } 637 637 638 if ( is_admin() || defined( 'WP_INSTALLING') || ( defined( 'WP_REPAIRING' ) && WP_REPAIRING ) ) {638 if ( is_admin() || wp_installing() || ( defined( 'WP_REPAIRING' ) && WP_REPAIRING ) ) { 639 639 load_textdomain( 'default', WP_LANG_DIR . "/admin-$locale.mo" ); 640 640 } -
trunk/src/wp-includes/load.php
r34462 r34828 166 166 */ 167 167 function wp_maintenance() { 168 if ( ! file_exists( ABSPATH . '.maintenance' ) || defined( 'WP_INSTALLING') )168 if ( ! file_exists( ABSPATH . '.maintenance' ) || wp_installing() ) 169 169 return; 170 170 … … 476 476 function wp_not_installed() { 477 477 if ( is_multisite() ) { 478 if ( ! is_blog_installed() && ! defined( 'WP_INSTALLING') ) {478 if ( ! is_blog_installed() && ! wp_installing() ) { 479 479 nocache_headers(); 480 480 481 481 wp_die( __( 'The site you have requested is not installed properly. Please contact the system administrator.' ) ); 482 482 } 483 } elseif ( ! is_blog_installed() && ! defined( 'WP_INSTALLING') ) {483 } elseif ( ! is_blog_installed() && ! wp_installing() ) { 484 484 nocache_headers(); 485 485 … … 540 540 $plugins = array(); 541 541 $active_plugins = (array) get_option( 'active_plugins', array() ); 542 if ( empty( $active_plugins ) || defined( 'WP_INSTALLING') )542 if ( empty( $active_plugins ) || wp_installing() ) 543 543 return $plugins; 544 544 -
trunk/src/wp-includes/ms-functions.php
r34778 r34828 1117 1117 return new WP_Error( 'blog_taken', __( 'Sorry, that site already exists!' ) ); 1118 1118 1119 if ( !defined('WP_INSTALLING') ) 1120 define( 'WP_INSTALLING', true ); 1119 if ( ! wp_installing() ) { 1120 wp_installing( true ); 1121 } 1121 1122 1122 1123 if ( ! $blog_id = insert_blog($domain, $path, $site_id) ) … … 2173 2174 return; 2174 2175 2175 if ( ! wp_next_scheduled('update_network_counts') && !defined('WP_INSTALLING') )2176 if ( ! wp_next_scheduled('update_network_counts') && ! wp_installing() ) 2176 2177 wp_schedule_event(time(), 'twicedaily', 'update_network_counts'); 2177 2178 } -
trunk/src/wp-includes/ms-settings.php
r34819 r34828 137 137 138 138 // @todo Investigate when exactly this can occur. 139 if ( empty( $current_blog ) && defined( 'WP_INSTALLING') ) {139 if ( empty( $current_blog ) && wp_installing() ) { 140 140 $current_blog = new stdClass; 141 141 $current_blog->blog_id = $blog_id = 1; -
trunk/src/wp-includes/option.php
r34779 r34828 54 54 return false; 55 55 56 if ( ! defined( 'WP_INSTALLING') ) {56 if ( ! wp_installing() ) { 57 57 // prevent non-existent options from triggering multiple queries 58 58 $notoptions = wp_cache_get( 'notoptions', 'options' ); … … 172 172 global $wpdb; 173 173 174 if ( ! defined( 'WP_INSTALLING' ) || !is_multisite() )174 if ( ! wp_installing() || ! is_multisite() ) 175 175 $alloptions = wp_cache_get( 'alloptions', 'options' ); 176 176 else … … 186 186 $alloptions[$o->option_name] = $o->option_value; 187 187 } 188 if ( ! defined( 'WP_INSTALLING' ) || !is_multisite() )188 if ( ! wp_installing() || ! is_multisite() ) 189 189 wp_cache_add( 'alloptions', $alloptions, 'options' ); 190 190 } … … 205 205 global $wpdb; 206 206 207 if ( ! is_multisite() || wp_using_ext_object_cache() || defined( 'WP_INSTALLING') )207 if ( ! is_multisite() || wp_using_ext_object_cache() || wp_installing() ) 208 208 return; 209 209 … … 333 333 } 334 334 335 if ( ! defined( 'WP_INSTALLING') ) {335 if ( ! wp_installing() ) { 336 336 $alloptions = wp_load_alloptions(); 337 337 if ( isset( $alloptions[$option] ) ) { … … 434 434 return false; 435 435 436 if ( ! defined( 'WP_INSTALLING') ) {436 if ( ! wp_installing() ) { 437 437 if ( 'yes' == $autoload ) { 438 438 $alloptions = wp_load_alloptions(); … … 510 510 511 511 $result = $wpdb->delete( $wpdb->options, array( 'option_name' => $option ) ); 512 if ( ! defined( 'WP_INSTALLING') ) {512 if ( ! wp_installing() ) { 513 513 if ( 'yes' == $row->autoload ) { 514 514 $alloptions = wp_load_alloptions(); … … 630 630 } else { 631 631 $transient_option = '_transient_' . $transient; 632 if ( ! defined( 'WP_INSTALLING') ) {632 if ( ! wp_installing() ) { 633 633 // If option is not in alloptions, it is not autoloaded and thus has a timeout 634 634 $alloptions = wp_load_alloptions(); -
trunk/src/wp-includes/script-loader.php
r34778 r34828 830 830 global $_wp_admin_css_colors; 831 831 832 if ( defined('WP_INSTALLING') )832 if ( wp_installing() ) 833 833 return preg_replace( '#^wp-admin/#', './', $src ); 834 834 -
trunk/src/wp-includes/theme.php
r34554 r34828 772 772 * @param bool true Validation flag to check the current theme. 773 773 */ 774 if ( defined('WP_INSTALLING') || ! apply_filters( 'validate_current_theme', true ) )774 if ( wp_installing() || ! apply_filters( 'validate_current_theme', true ) ) 775 775 return true; 776 776 -
trunk/src/wp-includes/update.php
r32635 r34828 23 23 */ 24 24 function wp_version_check( $extra_stats = array(), $force_check = false ) { 25 if ( defined( 'WP_INSTALLING') ) {25 if ( wp_installing() ) { 26 26 return; 27 27 } … … 188 188 */ 189 189 function wp_update_plugins( $extra_stats = array() ) { 190 if ( defined( 'WP_INSTALLING') ) {190 if ( wp_installing() ) { 191 191 return; 192 192 } … … 345 345 */ 346 346 function wp_update_themes( $extra_stats = array() ) { 347 if ( defined( 'WP_INSTALLING') ) {347 if ( wp_installing() ) { 348 348 return; 349 349 } … … 637 637 */ 638 638 function wp_schedule_update_checks() { 639 if ( ! wp_next_scheduled('wp_version_check') && !defined('WP_INSTALLING') )639 if ( ! wp_next_scheduled( 'wp_version_check' ) && ! wp_installing() ) 640 640 wp_schedule_event(time(), 'twicedaily', 'wp_version_check'); 641 641 642 if ( ! wp_next_scheduled('wp_update_plugins') && !defined('WP_INSTALLING') )642 if ( ! wp_next_scheduled( 'wp_update_plugins' ) && ! wp_installing() ) 643 643 wp_schedule_event(time(), 'twicedaily', 'wp_update_plugins'); 644 644 645 if ( ! wp_next_scheduled('wp_update_themes') && !defined('WP_INSTALLING') )645 if ( ! wp_next_scheduled( 'wp_update_themes' ) && ! wp_installing() ) 646 646 wp_schedule_event(time(), 'twicedaily', 'wp_update_themes'); 647 647 648 if ( ! wp_next_scheduled( 'wp_maybe_auto_update' ) && ! defined( 'WP_INSTALLING') ) {648 if ( ! wp_next_scheduled( 'wp_maybe_auto_update' ) && ! wp_installing() ) { 649 649 // Schedule auto updates for 7 a.m. and 7 p.m. in the timezone of the site. 650 650 $next = strtotime( 'today 7am' ); -
trunk/src/wp-settings.php
r33748 r34828 322 322 323 323 // Load the functions for the active theme, for both parent and child theme if applicable. 324 if ( ! defined( 'WP_INSTALLING') || 'wp-activate.php' === $pagenow ) {324 if ( ! wp_installing() || 'wp-activate.php' === $pagenow ) { 325 325 if ( TEMPLATEPATH !== STYLESHEETPATH && file_exists( STYLESHEETPATH . '/functions.php' ) ) 326 326 include( STYLESHEETPATH . '/functions.php' ); -
trunk/tests/phpunit/includes/factory.php
r32659 r34828 174 174 $blog = wpmu_create_blog( $args['domain'], $args['path'], $args['title'], $user_id, $meta, $args['site_id'] ); 175 175 $wpdb->suppress_errors( $suppress ); 176 177 // Tell WP we're done installing. 178 wp_installing( false ); 179 176 180 return $blog; 177 181 } -
trunk/tests/phpunit/includes/testcase.php
r34810 r34828 14 14 protected static $hooks_saved = array(); 15 15 protected static $ignore_files; 16 17 protected $db_version;18 16 19 17 /** … … 59 57 60 58 add_filter( 'wp_mail', array( $this, 'set_wp_mail_globals' ) ); 61 62 /*63 * During multisite tests, WP_INSTALLING forces `get_option()` to miss the cache, which causes problems64 * with our query-counting cache tests. As a workaround in the case of tests that require checking65 * 'db_version' (such as any test that uses the Term Meta API), we filter 'pre_option_db_version' and66 * avoid hitting the database.67 *68 * See #31130.69 */70 $this->db_version = get_option( 'db_version' );71 if ( is_multisite() ) {72 add_filter( 'pre_option_db_version', array( $this, 'db_version' ) );73 }74 59 } 75 60 … … 636 621 637 622 /** 638 * Return the current database version without hitting the database.639 *640 * This is used to bypass cache problems with some multisite tests. See #31130.641 *642 * @todo Don't do this anymore once #31130 is fixed.643 *644 * @since 4.4.0645 */646 public function db_version() {647 return $this->db_version;648 }649 650 /**651 623 * Utility method that resets permalinks and flushes rewrites. 652 624 * -
trunk/tests/phpunit/tests/comment/getPageOfComment.php
r34806 r34828 61 61 */ 62 62 public function test_subsequent_calls_should_hit_cache() { 63 // `get_page_of_comment()` calls `get_option()`, which is not properly cached when WP_INSTALLING.64 if ( is_multisite() ) {65 $this->markTestSkipped( 'Not testable in MS: wpmu_create_blog() defines WP_INSTALLING, which causes cache misses.' );66 }67 68 63 global $wpdb; 69 64 -
trunk/tests/phpunit/tests/general/archives.php
r31764 r34828 16 16 function test_get_archives_cache() { 17 17 global $wpdb; 18 19 if ( is_multisite() ) {20 $this->markTestSkipped( 'Not testable in MS: wpmu_create_blog() defines WP_INSTALLING, which causes cache misses.' );21 }22 18 23 19 $this->factory->post->create_many( 15, array( 'post_type' => 'post' ) ); -
trunk/tests/phpunit/tests/option/transient.php
r34767 r34828 47 47 */ 48 48 function test_transient_data_with_timeout() { 49 if ( is_multisite() ) {50 $this->markTestSkipped( 'Not testable in MS: wpmu_create_blog() defines WP_INSTALLING.' );51 }52 53 49 $key = rand_str(); 54 50 $value = rand_str(); … … 72 68 */ 73 69 function test_transient_add_timeout() { 74 if ( is_multisite() ) {75 $this->markTestSkipped( 'Not testable in MS: wpmu_create_blog() defines WP_INSTALLING.' );76 }77 78 70 $key = rand_str(); 79 71 $value = rand_str(); … … 127 119 */ 128 120 function test_nonexistent_key_old_timeout() { 129 if ( is_multisite() ) {130 $this->markTestSkipped( 'Not testable in MS: wpmu_create_blog() defines WP_INSTALLING.' );131 }132 133 121 // Create a transient 134 122 $key = 'test_transient'; -
trunk/tests/phpunit/tests/option/updateOption.php
r34766 r34828 21 21 */ 22 22 public function test_should_set_autoload_yes_for_nonexistent_option_when_autoload_param_is_missing() { 23 if ( is_multisite() ) {24 $this->markTestSkipped( 'Not testable in MS: wpmu_create_blog() defines WP_INSTALLING, which causes cache misses.' );25 }26 27 23 global $wpdb; 28 24 $this->flush_cache(); … … 45 41 */ 46 42 public function test_should_set_autoload_yes_for_nonexistent_option_when_autoload_param_is_yes() { 47 if ( is_multisite() ) {48 $this->markTestSkipped( 'Not testable in MS: wpmu_create_blog() defines WP_INSTALLING, which causes cache misses.' );49 }50 51 43 global $wpdb; 52 44 $this->flush_cache(); … … 69 61 */ 70 62 public function test_should_set_autoload_no_for_nonexistent_option_when_autoload_param_is_no() { 71 if ( is_multisite() ) {72 $this->markTestSkipped( 'Not testable in MS: wpmu_create_blog() defines WP_INSTALLING, which causes cache misses.' );73 }74 75 63 global $wpdb; 76 64 $this->flush_cache(); … … 94 82 */ 95 83 public function test_should_set_autoload_no_for_nonexistent_option_when_autoload_param_is_false() { 96 if ( is_multisite() ) {97 $this->markTestSkipped( 'Not testable in MS: wpmu_create_blog() defines WP_INSTALLING, which causes cache misses.' );98 }99 100 84 global $wpdb; 101 85 $this->flush_cache(); … … 119 103 */ 120 104 public function test_autoload_should_be_updated_for_existing_option_when_value_is_changed() { 121 if ( is_multisite() ) {122 $this->markTestSkipped( 'Not testable in MS: wpmu_create_blog() defines WP_INSTALLING, which causes cache misses.' );123 }124 125 105 global $wpdb; 126 106 add_option( 'foo', 'bar', '', 'no' ); … … 144 124 */ 145 125 public function test_autoload_should_not_be_updated_for_existing_option_when_value_is_unchanged() { 146 if ( is_multisite() ) {147 $this->markTestSkipped( 'Not testable in MS: wpmu_create_blog() defines WP_INSTALLING, which causes cache misses.' );148 }149 150 126 global $wpdb; 151 127 add_option( 'foo', 'bar', '', 'yes' ); … … 170 146 */ 171 147 public function test_autoload_should_not_be_updated_for_existing_option_when_value_is_changed_but_no_value_of_autoload_is_provided() { 172 if ( is_multisite() ) {173 $this->markTestSkipped( 'Not testable in MS: wpmu_create_blog() defines WP_INSTALLING, which causes cache misses.' );174 }175 176 148 global $wpdb; 177 149 add_option( 'foo', 'bar', '', 'yes' ); -
trunk/tests/phpunit/tests/post/getPostClass.php
r32997 r34828 109 109 global $wpdb; 110 110 111 if ( is_multisite() ) {112 $this->markTestSkipped( 'Not testable in MS: wpmu_create_blog() defines WP_INSTALLING, which causes cache misses.' );113 }114 115 111 register_taxonomy( 'wptests_tax', 'post' ); 116 112 wp_set_post_terms( $this->post_id, array( 'foo', 'bar' ), 'wptests_tax' ); -
trunk/tests/phpunit/tests/term/getTerms.php
r34529 r34828 382 382 public function test_child_of_should_skip_query_when_specified_parent_is_not_found_in_hierarchy_cache() { 383 383 global $wpdb; 384 385 if ( is_multisite() ) {386 $this->markTestSkipped( 'Not testable in MS: wpmu_create_blog() defines WP_INSTALLING, which causes cache misses.' );387 }388 384 389 385 register_taxonomy( 'wptests_tax', 'post', array( 'hierarchical' => true, ) ); … … 1328 1324 global $wpdb; 1329 1325 1330 if ( is_multisite() ) {1331 $this->markTestSkipped( 'Not testable in MS: wpmu_create_blog() defines WP_INSTALLING, which causes cache misses.' );1332 }1333 1334 1326 register_taxonomy( 'wptests_tax', 'post', array( 'hierarchical' => true, ) ); 1335 1327 -
trunk/tests/phpunit/tests/term/wpInsertTerm.php
r34809 r34828 469 469 */ 470 470 public function test_wp_insert_term_duplicate_slug_different_taxonomy_before_410_schema_change() { 471 472 // See #31130.473 471 $old_db_version = 30055; 474 if ( is_multisite() ) { 475 $_db_version = $this->db_version; 476 $this->db_version = $old_db_version; 477 } else { 478 update_option( 'db_version', $old_db_version ); 479 } 472 update_option( 'db_version', $old_db_version ); 480 473 481 474 register_taxonomy( 'wptests_tax', 'post' ); … … 503 496 $this->assertSame( 'foo-2', $new_term->slug ); 504 497 $this->assertNotEquals( $new_term->term_id, $term->term_id ); 505 506 if ( is_multisite() ) {507 $this->db_version = $_db_version;508 }509 498 510 499 _unregister_taxonomy( 'wptests_tax', 'post' ); -
trunk/tests/phpunit/tests/user/capabilities.php
r34450 r34828 874 874 875 875 function test_current_user_can_for_blog() { 876 global $wpdb; 877 876 878 $user = new WP_User( $this->factory->user->create( array( 'role' => 'administrator' ) ) ); 877 879 $old_uid = get_current_user_id(); … … 885 887 } 886 888 889 $suppress = $wpdb->suppress_errors(); 887 890 $this->assertFalse( current_user_can_for_blog( 12345, 'edit_posts' ) ); 891 $wpdb->suppress_errors( $suppress ); 888 892 889 893 $blog_id = $this->factory->blog->create( array( 'user_id' => $user->ID ) );
Note: See TracChangeset
for help on using the changeset viewer.