Make WordPress Core


Ignore:
Timestamp:
10/05/2015 03:05:26 PM (9 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/src/wp-includes/update.php

    r32635 r34828  
    2323 */
    2424function wp_version_check( $extra_stats = array(), $force_check = false ) {
    25     if ( defined( 'WP_INSTALLING' ) ) {
     25    if ( wp_installing() ) {
    2626        return;
    2727    }
     
    188188 */
    189189function wp_update_plugins( $extra_stats = array() ) {
    190     if ( defined( 'WP_INSTALLING' ) ) {
     190    if ( wp_installing() ) {
    191191        return;
    192192    }
     
    345345 */
    346346function wp_update_themes( $extra_stats = array() ) {
    347     if ( defined( 'WP_INSTALLING' ) ) {
     347    if ( wp_installing() ) {
    348348        return;
    349349    }
     
    637637 */
    638638function 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() )
    640640        wp_schedule_event(time(), 'twicedaily', 'wp_version_check');
    641641
    642     if ( !wp_next_scheduled('wp_update_plugins') && !defined('WP_INSTALLING') )
     642    if ( ! wp_next_scheduled( 'wp_update_plugins' ) && ! wp_installing() )
    643643        wp_schedule_event(time(), 'twicedaily', 'wp_update_plugins');
    644644
    645     if ( !wp_next_scheduled('wp_update_themes') && !defined('WP_INSTALLING') )
     645    if ( ! wp_next_scheduled( 'wp_update_themes' ) && ! wp_installing() )
    646646        wp_schedule_event(time(), 'twicedaily', 'wp_update_themes');
    647647
    648     if ( ! wp_next_scheduled( 'wp_maybe_auto_update' ) && ! defined( 'WP_INSTALLING' ) ) {
     648    if ( ! wp_next_scheduled( 'wp_maybe_auto_update' ) && ! wp_installing() ) {
    649649        // Schedule auto updates for 7 a.m. and 7 p.m. in the timezone of the site.
    650650        $next = strtotime( 'today 7am' );
Note: See TracChangeset for help on using the changeset viewer.