| 50 | | /** |
| 51 | | * Filters whether to attempt to perform the multisite DB upgrade routine. |
| 52 | | * |
| 53 | | * In single site, the user would be redirected to wp-admin/upgrade.php. |
| 54 | | * In multisite, the DB upgrade routine is automatically fired, but only |
| 55 | | * when this filter returns true. |
| 56 | | * |
| 57 | | * If the network is 50 sites or less, it will run every time. Otherwise, |
| 58 | | * it will throttle itself to reduce load. |
| 59 | | * |
| 60 | | * @since 3.0.0 |
| 61 | | * |
| 62 | | * @param bool $do_mu_upgrade Whether to perform the Multisite upgrade routine. Default true. |
| 63 | | */ |
| 64 | | } elseif ( apply_filters( 'do_mu_upgrade', true ) ) { |
| 65 | | $c = get_blog_count(); |
| | 47 | // Make sure the DB version isn't stale in cache |
| | 48 | wp_installing( true ); |
| 67 | | /* |
| 68 | | * If there are 50 or fewer sites, run every time. Otherwise, throttle to reduce load: |
| 69 | | * attempt to do no more than threshold value, with some +/- allowed. |
| | 50 | if ( get_option('db_version') == $wp_db_version ) { |
| | 51 | |
| | 52 | wp_installing( false ); |
| | 53 | wp_cache_flush(); |
| | 54 | wp_cache_delete( 'alloptions', 'site-options' ); |
| | 55 | |
| | 56 | } else { |
| | 57 | |
| | 58 | if ( !is_multisite() ) { |
| | 59 | wp_redirect( admin_url( 'upgrade.php?_wp_http_referer=' . urlencode( wp_unslash( $_SERVER['REQUEST_URI'] ) ) ) ); |
| | 60 | exit; |
| | 61 | |
| | 62 | /** |
| | 63 | * Filters whether to attempt to perform the multisite DB upgrade routine. |
| | 64 | * |
| | 65 | * In single site, the user would be redirected to wp-admin/upgrade.php. |
| | 66 | * In multisite, the DB upgrade routine is automatically fired, but only |
| | 67 | * when this filter returns true. |
| | 68 | * |
| | 69 | * If the network is 50 sites or less, it will run every time. Otherwise, |
| | 70 | * it will throttle itself to reduce load. |
| | 71 | * |
| | 72 | * @since 3.0.0 |
| | 73 | * |
| | 74 | * @param bool $do_mu_upgrade Whether to perform the Multisite upgrade routine. Default true. |
| 71 | | if ( $c <= 50 || ( $c > 50 && mt_rand( 0, (int)( $c / 50 ) ) == 1 ) ) { |
| 72 | | require_once( ABSPATH . WPINC . '/http.php' ); |
| 73 | | $response = wp_remote_get( admin_url( 'upgrade.php?step=1' ), array( 'timeout' => 120, 'httpversion' => '1.1' ) ); |
| 74 | | /** This action is documented in wp-admin/network/upgrade.php */ |
| 75 | | do_action( 'after_mu_upgrade', $response ); |
| 76 | | unset($response); |
| | 76 | } elseif ( apply_filters( 'do_mu_upgrade', true ) ) { |
| | 77 | $c = get_blog_count(); |
| | 78 | |
| | 79 | /* |
| | 80 | * If there are 50 or fewer sites, run every time. Otherwise, throttle to reduce load: |
| | 81 | * attempt to do no more than threshold value, with some +/- allowed. |
| | 82 | */ |
| | 83 | if ( $c <= 50 || ( $c > 50 && mt_rand( 0, (int)( $c / 50 ) ) == 1 ) ) { |
| | 84 | require_once( ABSPATH . WPINC . '/http.php' ); |
| | 85 | $response = wp_remote_get( admin_url( 'upgrade.php?step=1' ), array( 'timeout' => 120, 'httpversion' => '1.1' ) ); |
| | 86 | /** This action is documented in wp-admin/network/upgrade.php */ |
| | 87 | do_action( 'after_mu_upgrade', $response ); |
| | 88 | unset($response); |
| | 89 | } |
| | 90 | unset($c); |