maintenance: Remove unused code from several maintenance scripts
authorThiemo Kreuz <thiemo.kreuz@wikimedia.de>
Thu, 28 Feb 2019 11:04:31 +0000 (12:04 +0100)
committerUmherirrender <umherirrender_de.wp@web.de>
Sun, 3 Mar 2019 16:57:19 +0000 (16:57 +0000)
The most notable removal is done in the orphans script. This code was
really never used. Brion introduced it in 2005, already disabled.

I have all the respect for what Brion did. I just think it does not make
much sense to keep code around for so long if it does not work anyway,
and must be rewritten from scratch anyway now that we have multi-content
revisions and such.

Change-Id: I4e8050929f90e44a6e6051bf938993a8b0cdf649

12 files changed:
maintenance/cleanupPreferences.php
maintenance/deleteBatch.php
maintenance/includes/BackupDumper.php
maintenance/includes/MigrateActors.php
maintenance/mergeMessageFileList.php
maintenance/mysql.php
maintenance/orphans.php
maintenance/pageExists.php
maintenance/populateBacklinkNamespace.php
maintenance/protect.php
maintenance/updateCollation.php
maintenance/updateSpecialPages.php

index a52ce17..a6399f6 100644 (file)
@@ -60,7 +60,6 @@ class CleanupPreferences extends Maintenance {
                global $wgHiddenPrefs, $wgDefaultUserOptions;
 
                $dbw = $this->getDB( DB_MASTER );
-               $didWork = false;
                $hidden = $this->hasOption( 'hidden' );
                $unknown = $this->hasOption( 'unknown' );
                $bogus = $this->hasOption( 'bogus' );
index 09e8211..fe3bea0 100644 (file)
@@ -80,8 +80,6 @@ class DeleteBatch extends Maintenance {
                        $this->fatalError( "Unable to read file, exiting" );
                }
 
-               $dbw = $this->getDB( DB_MASTER );
-
                # Handle each entry
                for ( $linenum = 1; !feof( $file ); $linenum++ ) {
                        $line = trim( fgets( $file ) );
index 673ea7f..45786d8 100644 (file)
@@ -74,9 +74,6 @@ abstract class BackupDumper extends Maintenance {
        /** @var LoadBalancer */
        protected $lb;
 
-       // @todo Unused?
-       private $stubText = false; // include rev_text_id instead of text; for 2-pass dump
-
        /**
         * @param array|null $args For backward compatibility
         */
index 813f88e..ba6c375 100644 (file)
@@ -414,7 +414,6 @@ class MigrateActors extends LoggedUpdateMaintenance {
                $complainedAboutUsers = [];
 
                $primaryKey = [ 'ls_value', 'ls_log_id' ];
-               $pkFilter = array_flip( $primaryKey );
                $this->output( "Beginning migration of log_search\n" );
                wfWaitForSlaves();
 
index 6ae506f..80e72fb 100644 (file)
@@ -77,7 +77,6 @@ class MergeMessageFileList extends Maintenance {
                        $extdir = $this->getOption( 'extensions-dir' );
                        # Allow multiple directories to be passed with ":" as delimiter
                        $extdirs = explode( ':', $extdir );
-                       $entries = [];
                        foreach ( $extdirs as $extdir ) {
                                $entries = scandir( $extdir );
                                foreach ( $entries as $extname ) {
index 9424402..34a6cb6 100644 (file)
@@ -72,8 +72,6 @@ class MysqlMaintenance extends Maintenance {
                        $host = $this->getOption( 'host' );
                        $serverCount = $lb->getServerCount();
                        for ( $index = 0; $index < $serverCount; ++$index ) {
-                               $serverInfo = $lb->getServerInfo( $index );
-
                                if ( $lb->getServerName( $index ) === $host ) {
                                        break;
                                }
index d47ca43..bfae4b7 100644 (file)
@@ -53,8 +53,6 @@ class Orphans extends Maintenance {
        public function execute() {
                $this->checkOrphans( $this->hasOption( 'fix' ) );
                $this->checkSeparation( $this->hasOption( 'fix' ) );
-               # Does not work yet, do not use
-               # $this->checkWidows( $this->hasOption( 'fix' ) );
        }
 
        /**
@@ -67,7 +65,7 @@ class Orphans extends Maintenance {
                if ( $extraTable ) {
                        $tbls = array_merge( $tbls, $extraTable );
                }
-               $db->lockTables( [], $tbls, __METHOD__, false );
+               $db->lockTables( [], $tbls, __METHOD__ );
        }
 
        /**
@@ -139,54 +137,6 @@ class Orphans extends Maintenance {
                }
        }
 
-       /**
-        * @param bool $fix
-        * @todo DON'T USE THIS YET! It will remove entries which have children,
-        *       but which aren't properly attached (eg if page_latest is bogus
-        *       but valid revisions do exist)
-        */
-       private function checkWidows( $fix ) {
-               $dbw = $this->getDB( DB_MASTER );
-               $page = $dbw->tableName( 'page' );
-               $revision = $dbw->tableName( 'revision' );
-
-               if ( $fix ) {
-                       $this->lockTables( $dbw );
-               }
-
-               $this->output( "\nChecking for childless page table entries... "
-                       . "(this may take a while on a large wiki)\n" );
-               $result = $dbw->query( "
-                       SELECT *
-                       FROM $page LEFT OUTER JOIN $revision ON page_latest=rev_id
-                       WHERE rev_id IS NULL
-               " );
-               $widows = $result->numRows();
-               if ( $widows > 0 ) {
-                       $this->output( "$widows childless pages...\n" );
-                       $this->output( sprintf( "%10s %11s %2s %s\n", 'page_id', 'page_latest', 'ns', 'page_title' ) );
-                       foreach ( $result as $row ) {
-                               printf( "%10d %11d %2d %s\n",
-                                       $row->page_id,
-                                       $row->page_latest,
-                                       $row->page_namespace,
-                                       $row->page_title );
-                               if ( $fix ) {
-                                       $dbw->delete( 'page', [ 'page_id' => $row->page_id ] );
-                               }
-                       }
-                       if ( !$fix ) {
-                               $this->output( "Run again with --fix to remove these entries automatically.\n" );
-                       }
-               } else {
-                       $this->output( "No childless pages! Yay!\n" );
-               }
-
-               if ( $fix ) {
-                       $dbw->unlockTables( __METHOD__ );
-               }
-       }
-
        /**
         * Check for pages where page_latest is wrong
         * @param bool $fix Whether to fix broken entries
index dc9bbda..10d37de 100644 (file)
@@ -36,7 +36,6 @@ class PageExists extends Maintenance {
                $title = Title::newFromText( $titleArg );
                $pageExists = $title && $title->exists();
 
-               $text = '';
                $code = 0;
                if ( $pageExists ) {
                        $text = "{$title} exists.";
index e2fd8b5..ac52721 100644 (file)
@@ -44,8 +44,6 @@ class PopulateBacklinkNamespace extends LoggedUpdateMaintenance {
        }
 
        public function doDBUpdates() {
-               $force = $this->getOption( 'force' );
-
                $db = $this->getDB( DB_MASTER );
 
                $this->output( "Updating *_from_namespace fields in links tables.\n" );
index b47476a..e2c1a8b 100644 (file)
@@ -62,9 +62,6 @@ class Protect extends Maintenance {
                        $this->fatalError( "Invalid username" );
                }
 
-               // @todo FIXME: This is reset 7 lines down.
-               $restrictions = [ 'edit' => $protection, 'move' => $protection ];
-
                $t = Title::newFromText( $this->getArg() );
                if ( !$t ) {
                        $this->fatalError( "Invalid title" );
index 12b33b4..ab40e48 100644 (file)
@@ -142,7 +142,6 @@ TEXT
                        wfWaitForSlaves();
                }
                $count = 0;
-               $batchCount = 0;
                $batchConds = [];
                do {
                        $this->output( "Selecting next " . self::BATCH_SIZE . " rows..." );
index 3b28b65..5d756e8 100644 (file)
@@ -49,7 +49,7 @@ class UpdateSpecialPages extends Maintenance {
                $this->doSpecialPageCacheUpdates( $dbw );
 
                foreach ( QueryPage::getPages() as $page ) {
-                       list( $class, $special ) = $page;
+                       list( , $special ) = $page;
                        $limit = $page[2] ?? null;
 
                        # --list : just show the name of pages