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.

Built from https://develop.svn.wordpress.org/trunk@38680


git-svn-id: http://core.svn.wordpress.org/trunk@38623 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Jeremy Felt 2016-09-30 03:51:30 +00:00
parent 0aca312697
commit 0dc18d3ffb
2 changed files with 17 additions and 7 deletions

View File

@ -52,14 +52,24 @@ switch ( $action ) {
update_site_option( 'wpmu_upgrade_site', $wp_db_version ); update_site_option( 'wpmu_upgrade_site', $wp_db_version );
} }
$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 ); $site_ids = get_sites( array(
if ( empty( $blogs ) ) { 'spam' => '0',
'deleted' => '0',
'archived' => '0',
'network_id' => get_current_network_id(),
'number' => 5,
'offset' => $n,
'fields' => 'ids',
'order' => 'DESC',
'orderby' => 'id',
) );
if ( empty( $site_ids ) ) {
echo '<p>' . __( 'All done!' ) . '</p>'; echo '<p>' . __( 'All done!' ) . '</p>';
break; break;
} }
echo "<ul>"; echo "<ul>";
foreach ( (array) $blogs as $details ) { foreach ( (array) $site_ids as $site_id ) {
switch_to_blog( $details['blog_id'] ); switch_to_blog( $site_id );
$siteurl = site_url(); $siteurl = site_url();
$upgrade_url = admin_url( 'upgrade.php?step=upgrade_db' ); $upgrade_url = admin_url( 'upgrade.php?step=upgrade_db' );
restore_current_blog(); restore_current_blog();
@ -93,9 +103,9 @@ switch ( $action ) {
* *
* @since MU * @since MU
* *
* @param int $blog_id The Site ID. * @param int $site_id The Site ID.
*/ */
do_action( 'wpmu_upgrade_site', $details[ 'blog_id' ] ); do_action( 'wpmu_upgrade_site', $site_id );
} }
echo "</ul>"; echo "</ul>";
?><p><?php _e( 'If your browser doesn&#8217;t start loading the next page automatically, click this link:' ); ?> <a class="button" href="upgrade.php?action=upgrade&amp;n=<?php echo ($n + 5) ?>"><?php _e("Next Sites"); ?></a></p> ?><p><?php _e( 'If your browser doesn&#8217;t start loading the next page automatically, click this link:' ); ?> <a class="button" href="upgrade.php?action=upgrade&amp;n=<?php echo ($n + 5) ?>"><?php _e("Next Sites"); ?></a></p>

View File

@ -4,7 +4,7 @@
* *
* @global string $wp_version * @global string $wp_version
*/ */
$wp_version = '4.7-alpha-38679'; $wp_version = '4.7-alpha-38680';
/** /**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema. * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.