Skip to content

Commit c1c1844

Browse files
Copilotswissspidy
andcommitted
Optimize network metadata update to use network_id directly
Since all blogs are filtered by site_id = network_id, there's no need to collect and deduplicate site_ids. Directly use network_id for the metadata update. Co-authored-by: swissspidy <[email protected]>
1 parent 67cef5c commit c1c1844

File tree

1 file changed

+3
-7
lines changed

1 file changed

+3
-7
lines changed

src/Core_Command.php

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1342,16 +1342,14 @@ public function update_db( $args, $assoc_args ) {
13421342
$it = new TableIterator( $iterator_args );
13431343
$success = 0;
13441344
$total = 0;
1345-
$site_ids = [];
13461345

13471346
/**
13481347
* @var object{site_id: int, domain: string, path: string} $blog
13491348
*/
13501349
foreach ( $it as $blog ) {
13511350
++$total;
1352-
$site_ids[] = $blog->site_id;
1353-
$url = $blog->domain . $blog->path;
1354-
$cmd = "--url={$url} core update-db";
1351+
$url = $blog->domain . $blog->path;
1352+
$cmd = "--url={$url} core update-db";
13551353
if ( $dry_run ) {
13561354
$cmd .= ' --dry-run';
13571355
}
@@ -1381,9 +1379,7 @@ public function update_db( $args, $assoc_args ) {
13811379
}
13821380
}
13831381
if ( ! $dry_run && $total && $success === $total ) {
1384-
foreach ( array_unique( $site_ids ) as $site_id ) {
1385-
update_metadata( 'site', $site_id, 'wpmu_upgrade_site', $wp_db_version );
1386-
}
1382+
update_metadata( 'site', $network_id, 'wpmu_upgrade_site', $wp_db_version );
13871383
}
13881384
WP_CLI::success( "WordPress database upgraded on {$success}/{$total} sites." );
13891385
} else {

0 commit comments

Comments
 (0)