Merge "Replace wfWiki() usage with WikiMap in some additional places"
authorjenkins-bot <jenkins-bot@gerrit.wikimedia.org>
Tue, 23 Jul 2019 15:02:47 +0000 (15:02 +0000)
committerGerrit Code Review <gerrit@wikimedia.org>
Tue, 23 Jul 2019 15:02:47 +0000 (15:02 +0000)
1  2 
maintenance/cleanupSpam.php
maintenance/includes/TextPassDumper.php
maintenance/storage/recompressTracked.php

@@@ -21,8 -21,6 +21,8 @@@
   * @ingroup Maintenance
   */
  
 +use MediaWiki\Storage\RevisionRecord;
 +
  require_once __DIR__ . '/Maintenance.php';
  
  /**
@@@ -69,9 -67,9 +69,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(
@@@ -84,9 -82,9 +84,9 @@@
                                                $found = true;
                                                $cmd = wfShellWikiCmd(
                                                        "$IP/maintenance/cleanupSpam.php",
-                                                       [ '--wiki', $wikiID, $spec ]
+                                                       [ '--wiki', $wikiId, $spec ]
                                                );
-                                               passthru( "$cmd | sed 's/^/$wikiID:  /'" );
+                                               passthru( "$cmd | sed 's/^/$wikiId:  /'" );
                                        }
                                }
                        }
                $rev = Revision::newFromTitle( $title );
                $currentRevId = $rev->getId();
  
 -              while ( $rev && ( $rev->isDeleted( Revision::DELETED_TEXT )
 -                      || LinkFilter::matchEntry( $rev->getContent( Revision::RAW ), $domain, $protocol ) )
 +              while ( $rev && ( $rev->isDeleted( RevisionRecord::DELETED_TEXT )
 +                      || LinkFilter::matchEntry( $rev->getContent( RevisionRecord::RAW ), $domain, $protocol ) )
                ) {
                        $rev = $rev->getPrevious();
                }
                        $page = WikiPage::factory( $title );
                        if ( $rev ) {
                                // Revert to this revision
 -                              $content = $rev->getContent( Revision::RAW );
 +                              $content = $rev->getContent( RevisionRecord::RAW );
  
                                $this->output( "reverting\n" );
                                $page->doEditContent(
@@@ -373,13 -373,11 +373,13 @@@ TEX
                                $pageRatePart = '-';
                                $revRatePart = '-';
                        }
 +
 +                      $dbDomain = WikiMap::getCurrentWikiDbDomain()->getId();
                        $this->progress( sprintf(
                                "%s: %s (ID %d) %d pages (%0.1f|%0.1f/sec all|curr), "
                                        . "%d revs (%0.1f|%0.1f/sec all|curr), %0.1f%%|%0.1f%% "
                                        . "prefetched (all|curr), ETA %s [max %d]",
 -                              $now, wfWikiID(), $this->ID, $this->pageCount, $pageRate,
 +                              $now, $dbDomain, $this->ID, $this->pageCount, $pageRate,
                                $pageRatePart, $this->revCount, $revRate, $revRatePart,
                                $fetchRate, $fetchRatePart, $etats, $this->maxCount
                        ) );
        function openSpawn() {
                global $IP;
  
+               $wiki = WikiMap::getWikiIdFromDbDomain( WikiMap::getCurrentWikiDbDomain() );
                if ( count( $this->php ) == 2 ) {
                        $mwscriptpath = $this->php[1];
                } else {
                                                $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" ],
@@@ -148,7 -148,7 +148,7 @@@ class RecompressTracked 
                if ( $this->replicaId !== false ) {
                        $header .= "({$this->replicaId})";
                }
 -              $header .= ' ' . wfWikiID();
 +              $header .= ' ' . WikiMap::getCurrentWikiDbDomain()->getId();
                LegacyLogger::emit( sprintf( "%-50s %s\n", $header, $msg ), $file );
        }
  
         * 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' ) {
                        }
                }
                $cmd .= ' --child' .
-                       ' --wiki ' . Shell::escape( wfWikiID() ) .
+                       ' --wiki ' . Shell::escape( $wiki ) .
                        ' ' . Shell::escape( ...$this->destClusters );
  
                $this->replicaPipes = $this->replicaProcs = [];