Make WordPress Core


Ignore:
Timestamp:
10/05/2015 03:05:26 PM (10 years ago)
Author:
boonebgorges
Message:

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 wordpress.org 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
suite.

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.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/tests/option/updateOption.php

    r34766 r34828  
    2121     */
    2222    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 
    2723        global $wpdb;
    2824        $this->flush_cache();
     
    4541     */
    4642    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 
    5143        global $wpdb;
    5244        $this->flush_cache();
     
    6961     */
    7062    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 
    7563        global $wpdb;
    7664        $this->flush_cache();
     
    9482     */
    9583    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 
    10084        global $wpdb;
    10185        $this->flush_cache();
     
    119103     */
    120104    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 
    125105        global $wpdb;
    126106        add_option( 'foo', 'bar', '', 'no' );
     
    144124     */
    145125    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 
    150126        global $wpdb;
    151127        add_option( 'foo', 'bar', '', 'yes' );
     
    170146     */
    171147    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 
    176148        global $wpdb;
    177149        add_option( 'foo', 'bar', '', 'yes' );
Note: See TracChangeset for help on using the changeset viewer.