Make WordPress Core

10/05/2015 03:05:26 PM (8 years ago)

Use wp_installing() instead of WP_INSTALLING constant.

The WP_INSTALLING constant is a flag that WordPress sets in a number of
places, telling the system that options should be fetched directly from the
database instead of from the cache, that WP should not ping for
updates, that the normal "not installed" checks should be bypassed, and so on.

A constant is generally necessary for this purpose, because the flag is
typically set before the WP bootstrap, meaning that WP functions are not yet
available. However, it is possible - notably, during wpmu_create_blog() -
for the "installing" flag to be set after WP has already loaded. In these
cases, WP_INSTALLING would be set for the remainder of the process, since
there's no way to change a constant once it's defined. This, in turn, polluted
later function calls that ought to have been outside the scope of site
creation, particularly the non-caching of option data. The problem was
particularly evident in the case of the automated tests, where WP_INSTALLING
was set the first time a site was created, and remained set for the rest of the

The new wp_installing() function allows developers to fetch the current
installation status (when called without any arguments) or to set the
installation status (when called with a boolean true or false). Use of
the WP_INSTALLING constant is still supported; wp_installing() will default
to true if the constant is defined during the bootstrap.

Props boonebgorges, jeremyfelt.
See #31130.

1 edited


  • trunk/tests/phpunit/tests/term/wpInsertTerm.php

    r34809 r34828  
    469469     */
    470470    public function test_wp_insert_term_duplicate_slug_different_taxonomy_before_410_schema_change() {
    472         // See #31130.
    473471        $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 );
    481474        register_taxonomy( 'wptests_tax', 'post' );
    503496        $this->assertSame( 'foo-2', $new_term->slug );
    504497        $this->assertNotEquals( $new_term->term_id, $term->term_id );
    506         if ( is_multisite() ) {
    507             $this->db_version = $_db_version;
    508         }
    510499        _unregister_taxonomy( 'wptests_tax', 'post' );
Note: See TracChangeset for help on using the changeset viewer.