Merge "Introduce ContentHandler::getSecondaryDataUpdates."
[lhc/web/wiklou.git] / maintenance / cleanupAncientTables.php
index 694efaa..bcf4af2 100644 (file)
@@ -33,20 +33,21 @@ class CleanupAncientTables extends Maintenance {
 
        public function __construct() {
                parent::__construct();
-               $this->mDescription = "Cleanup ancient tables and indexes";
+               $this->addDescription( 'Cleanup ancient tables and indexes' );
                $this->addOption( 'force', 'Actually run this script' );
        }
 
        public function execute() {
                if ( !$this->hasOption( 'force' ) ) {
                        $this->error( "This maintenance script will remove old columns and indexes.\n"
-                               . "It is recommended to backup your database first, and ensure all your data has been migrated to newer tables\n"
-                               . "If you want to continue, run this script again with the --force \n"
+                               . "It is recommended to backup your database first, and ensure all your data has\n"
+                               . "been migrated to newer tables. If you want to continue, run this script again\n"
+                               . "with --force.\n"
                        );
                }
 
-               $db = wfGetDB( DB_MASTER );
-               $ancientTables = array(
+               $db = $this->getDB( DB_MASTER );
+               $ancientTables = [
                        'blobs', // 1.4
                        'brokenlinks', // 1.4
                        'cur', // 1.4
@@ -59,7 +60,7 @@ class CleanupAncientTables extends Maintenance {
                        'trackback', // 1.19
                        'user_rights', // 1.5
                        'validate', // 1.6
-               );
+               ];
 
                foreach ( $ancientTables as $table ) {
                        if ( $db->tableExists( $table, __METHOD__ ) ) {
@@ -71,23 +72,23 @@ class CleanupAncientTables extends Maintenance {
 
                $this->output( "Cleaning up text table\n" );
 
-               $oldIndexes = array(
+               $oldIndexes = [
                        'old_namespace',
                        'old_timestamp',
                        'name_title_timestamp',
                        'user_timestamp',
                        'usertext_timestamp',
-               );
+               ];
                foreach ( $oldIndexes as $index ) {
                        if ( $db->indexExists( 'text', $index, __METHOD__ ) ) {
                                $this->output( "Dropping index $index from the text table..." );
                                $db->query( "DROP INDEX " . $db->addIdentifierQuotes( $index )
-                                               . " ON " . $db->tableName( 'text' ) );
+                                       . " ON " . $db->tableName( 'text' ) );
                                $this->output( "done.\n" );
                        }
                }
 
-               $oldFields = array(
+               $oldFields = [
                        'old_namespace',
                        'old_title',
                        'old_comment',
@@ -96,12 +97,12 @@ class CleanupAncientTables extends Maintenance {
                        'old_timestamp',
                        'old_minor_edit',
                        'inverse_timestamp',
-               );
+               ];
                foreach ( $oldFields as $field ) {
                        if ( $db->fieldExists( 'text', $field, __METHOD__ ) ) {
                                $this->output( "Dropping the $field field from the text table..." );
                                $db->query( "ALTER TABLE  " . $db->tableName( 'text' )
-                                               . " DROP COLUMN " . $db->addIdentifierQuotes( $field )  );
+                                       . " DROP COLUMN " . $db->addIdentifierQuotes( $field ) );
                                $this->output( "done.\n" );
                        }
                }
@@ -109,5 +110,5 @@ class CleanupAncientTables extends Maintenance {
        }
 }
 
-$maintClass = "CleanupAncientTables";
+$maintClass = CleanupAncientTables::class;
 require_once RUN_MAINTENANCE_IF_MAIN;