From 12531d2ae6960c053d7382faf2403e2ae2e5b1f0 Mon Sep 17 00:00:00 2001 From: Aaron Schulz Date: Thu, 4 Jul 2019 01:28:18 -0700 Subject: [PATCH] Replace wfWiki() usage with WikiMap in some additional places Change-Id: Ide4518292bd9392d09f701b2c301673687d19f3b --- maintenance/cleanupSpam.php | 8 ++++---- maintenance/clearInterwikiCache.php | 6 +++--- maintenance/copyJobQueue.php | 3 ++- maintenance/generateSitemap.php | 6 ++++-- maintenance/includes/TextPassDumper.php | 5 +++-- maintenance/storage/recompressTracked.php | 4 +++- 6 files changed, 19 insertions(+), 13 deletions(-) diff --git a/maintenance/cleanupSpam.php b/maintenance/cleanupSpam.php index e1ea247377..27ada5911e 100644 --- a/maintenance/cleanupSpam.php +++ b/maintenance/cleanupSpam.php @@ -67,9 +67,9 @@ class CleanupSpam extends Maintenance { // Clean up spam on all wikis $this->output( "Finding spam on " . count( $wgLocalDatabases ) . " wikis\n" ); $found = false; - foreach ( $wgLocalDatabases as $wikiID ) { + foreach ( $wgLocalDatabases as $wikiId ) { /** @var Database $dbr */ - $dbr = $this->getDB( DB_REPLICA, [], $wikiID ); + $dbr = $this->getDB( DB_REPLICA, [], $wikiId ); foreach ( $protConds as $conds ) { $count = $dbr->selectField( @@ -82,9 +82,9 @@ class CleanupSpam extends Maintenance { $found = true; $cmd = wfShellWikiCmd( "$IP/maintenance/cleanupSpam.php", - [ '--wiki', $wikiID, $spec ] + [ '--wiki', $wikiId, $spec ] ); - passthru( "$cmd | sed 's/^/$wikiID: /'" ); + passthru( "$cmd | sed 's/^/$wikiId: /'" ); } } } diff --git a/maintenance/clearInterwikiCache.php b/maintenance/clearInterwikiCache.php index 8579f0f48a..45c66ae2dc 100644 --- a/maintenance/clearInterwikiCache.php +++ b/maintenance/clearInterwikiCache.php @@ -44,10 +44,10 @@ class ClearInterwikiCache extends Maintenance { $prefixes[] = $row->iw_prefix; } - foreach ( $wgLocalDatabases as $db ) { - $this->output( "$db..." ); + foreach ( $wgLocalDatabases as $wikiId ) { + $this->output( "$wikiId..." ); foreach ( $prefixes as $prefix ) { - $wgMemc->delete( "$db:interwiki:$prefix" ); + $wgMemc->delete( "$wikiId:interwiki:$prefix" ); } $this->output( "done\n" ); } diff --git a/maintenance/copyJobQueue.php b/maintenance/copyJobQueue.php index dc70e9c203..0e9614268f 100644 --- a/maintenance/copyJobQueue.php +++ b/maintenance/copyJobQueue.php @@ -57,8 +57,9 @@ class CopyJobQueue extends Maintenance { ? JobQueueGroup::singleton()->getQueueTypes() : [ $this->getOption( 'type' ) ]; + $dbDomain = WikiMap::getCurrentWikiDbDomain()->getId(); foreach ( $types as $type ) { - $baseConfig = [ 'type' => $type, 'wiki' => wfWikiID() ]; + $baseConfig = [ 'type' => $type, 'domain' => $dbDomain ]; $src = JobQueue::factory( $baseConfig + $wgJobQueueMigrationConfig[$srcKey] ); $dst = JobQueue::factory( $baseConfig + $wgJobQueueMigrationConfig[$dstKey] ); diff --git a/maintenance/generateSitemap.php b/maintenance/generateSitemap.php index 05dd0d08ab..aef45bff67 100644 --- a/maintenance/generateSitemap.php +++ b/maintenance/generateSitemap.php @@ -188,18 +188,20 @@ class GenerateSitemap extends Maintenance { $this->fatalError( "Can not create directory $fspath." ); } + $dbDomain = WikiMap::getCurrentWikiDbDomain()->getId(); $this->fspath = realpath( $fspath ) . DIRECTORY_SEPARATOR; $this->urlpath = $this->getOption( 'urlpath', "" ); if ( $this->urlpath !== "" && substr( $this->urlpath, -1 ) !== '/' ) { $this->urlpath .= '/'; } - $this->identifier = $this->getOption( 'identifier', wfWikiID() ); + $this->identifier = $this->getOption( 'identifier', $dbDomain ); $this->compress = $this->getOption( 'compress', 'yes' ) !== 'no'; $this->skipRedirects = $this->hasOption( 'skip-redirects' ); $this->dbr = $this->getDB( DB_REPLICA ); $this->generateNamespaces(); $this->timestamp = wfTimestamp( TS_ISO_8601, wfTimestampNow() ); - $this->findex = fopen( "{$this->fspath}sitemap-index-{$this->identifier}.xml", 'wb' ); + $encIdentifier = rawurlencode( $this->identifier ); + $this->findex = fopen( "{$this->fspath}sitemap-index-{$encIdentifier}.xml", 'wb' ); $this->main(); } diff --git a/maintenance/includes/TextPassDumper.php b/maintenance/includes/TextPassDumper.php index b37fec188e..8bc393fde9 100644 --- a/maintenance/includes/TextPassDumper.php +++ b/maintenance/includes/TextPassDumper.php @@ -757,6 +757,7 @@ TEXT function openSpawn() { global $IP; + $wiki = WikiMap::getWikiIdFromDbDomain( WikiMap::getCurrentWikiDbDomain() ); if ( count( $this->php ) == 2 ) { $mwscriptpath = $this->php[1]; } else { @@ -769,14 +770,14 @@ TEXT $this->php[0], $mwscriptpath, "fetchText.php", - '--wiki', wfWikiID() ] ) ); + '--wiki', $wiki ] ) ); } else { $cmd = implode( " ", array_map( [ Shell::class, 'escape' ], [ $this->php[0], "$IP/maintenance/fetchText.php", - '--wiki', wfWikiID() ] ) ); + '--wiki', $wiki ] ) ); } $spec = [ 0 => [ "pipe", "r" ], diff --git a/maintenance/storage/recompressTracked.php b/maintenance/storage/recompressTracked.php index e6733a184b..50a4667382 100644 --- a/maintenance/storage/recompressTracked.php +++ b/maintenance/storage/recompressTracked.php @@ -218,6 +218,8 @@ class RecompressTracked { * writing are all slow. */ function startReplicaProcs() { + $wiki = WikiMap::getWikiIdFromDbDomain( WikiMap::getCurrentWikiDbDomain() ); + $cmd = 'php ' . Shell::escape( __FILE__ ); foreach ( self::$cmdLineOptionMap as $cmdOption => $classOption ) { if ( $cmdOption == 'replica-id' ) { @@ -229,7 +231,7 @@ class RecompressTracked { } } $cmd .= ' --child' . - ' --wiki ' . Shell::escape( wfWikiID() ) . + ' --wiki ' . Shell::escape( $wiki ) . ' ' . Shell::escape( ...$this->destClusters ); $this->replicaPipes = $this->replicaProcs = []; -- 2.20.1