WordPress.org

Make WordPress Core

Changeset 38680


Ignore:
Timestamp:
09/30/2016 03:50:18 AM (4 years ago)
Author:
jeremyfelt
Message:

Multisite: Use get_sites() in network upgrade.

Use get_sites() to generate the same query that was previously performed manually.

Props spacedmonkey, flixos90.
Fixes #37823.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-admin/network/upgrade.php

    r38657 r38680  
    5353        }
    5454
    55         $blogs = $wpdb->get_results( "SELECT blog_id FROM {$wpdb->blogs} WHERE site_id = '{$wpdb->siteid}' AND spam = '0' AND deleted = '0' AND archived = '0' ORDER BY blog_id DESC LIMIT {$n}, 5", ARRAY_A );
    56         if ( empty( $blogs ) ) {
     55        $site_ids = get_sites( array(
     56            'spam'       => '0',
     57            'deleted'    => '0',
     58            'archived'   => '0',
     59            'network_id' => get_current_network_id(),
     60            'number'     => 5,
     61            'offset'     => $n,
     62            'fields'     => 'ids',
     63            'order'      => 'DESC',
     64            'orderby'    => 'id',
     65        ) );
     66        if ( empty( $site_ids ) ) {
    5767            echo '<p>' . __( 'All done!' ) . '</p>';
    5868            break;
    5969        }
    6070        echo "<ul>";
    61         foreach ( (array) $blogs as $details ) {
    62             switch_to_blog( $details['blog_id'] );
     71        foreach ( (array) $site_ids as $site_id ) {
     72            switch_to_blog( $site_id );
    6373            $siteurl = site_url();
    6474            $upgrade_url = admin_url( 'upgrade.php?step=upgrade_db' );
     
    94104             * @since MU
    95105             *
    96              * @param int $blog_id The Site ID.
     106             * @param int $site_id The Site ID.
    97107             */
    98             do_action( 'wpmu_upgrade_site', $details[ 'blog_id' ] );
     108            do_action( 'wpmu_upgrade_site', $site_id );
    99109        }
    100110        echo "</ul>";
Note: See TracChangeset for help on using the changeset viewer.