MediaWiki  1.23.12
cleanupAncientTables.php
Go to the documentation of this file.
1 <?php
24 require_once __DIR__ . '/Maintenance.php';
25 
33 
34  public function __construct() {
35  parent::__construct();
36  $this->mDescription = "Cleanup ancient tables and indexes";
37  $this->addOption( 'force', 'Actually run this script' );
38  }
39 
40  public function execute() {
41  if ( !$this->hasOption( 'force' ) ) {
42  $this->error( "This maintenance script will remove old columns and indexes.\n"
43  . "It is recommended to backup your database first, and ensure all your data has been migrated to newer tables\n"
44  . "If you want to continue, run this script again with the --force \n"
45  );
46  }
47 
48  $db = wfGetDB( DB_MASTER );
49  $ancientTables = array(
50  'blobs', // 1.4
51  'brokenlinks', // 1.4
52  'cur', // 1.4
53  'ip_blocks_old', // Temporary in 1.6
54  'links', // 1.4
55  'linkscc', // 1.4
56  // 'math', // 1.18, but don't want to drop if math extension is enabled...
57  'old', // 1.4
58  'oldwatchlist', // pre 1.1?
59  'trackback', // 1.19
60  'user_rights', // 1.5
61  'validate', // 1.6
62  );
63 
64  foreach ( $ancientTables as $table ) {
65  if ( $db->tableExists( $table, __METHOD__ ) ) {
66  $this->output( "Dropping table $table..." );
67  $db->dropTable( $table, __METHOD__ );
68  $this->output( "done.\n" );
69  }
70  }
71 
72  $this->output( "Cleaning up text table\n" );
73 
74  $oldIndexes = array(
75  'old_namespace',
76  'old_timestamp',
77  'name_title_timestamp',
78  'user_timestamp',
79  'usertext_timestamp',
80  );
81  foreach ( $oldIndexes as $index ) {
82  if ( $db->indexExists( 'text', $index, __METHOD__ ) ) {
83  $this->output( "Dropping index $index from the text table..." );
84  $db->query( "DROP INDEX " . $db->addIdentifierQuotes( $index )
85  . " ON " . $db->tableName( 'text' ) );
86  $this->output( "done.\n" );
87  }
88  }
89 
90  $oldFields = array(
91  'old_namespace',
92  'old_title',
93  'old_comment',
94  'old_user',
95  'old_user_text',
96  'old_timestamp',
97  'old_minor_edit',
98  'inverse_timestamp',
99  );
100  foreach ( $oldFields as $field ) {
101  if ( $db->fieldExists( 'text', $field, __METHOD__ ) ) {
102  $this->output( "Dropping the $field field from the text table..." );
103  $db->query( "ALTER TABLE " . $db->tableName( 'text' )
104  . " DROP COLUMN " . $db->addIdentifierQuotes( $field ) );
105  $this->output( "done.\n" );
106  }
107  }
108  $this->output( "Done!\n" );
109  }
110 }
111 
112 $maintClass = "CleanupAncientTables";
113 require_once RUN_MAINTENANCE_IF_MAIN;
$maintClass
$maintClass
Definition: cleanupAncientTables.php:112
DB_MASTER
const DB_MASTER
Definition: Defines.php:56
php
skin txt MediaWiki includes four core it has been set as the default in MediaWiki since the replacing Monobook it had been been the default skin since before being replaced by Vector largely rewritten in while keeping its appearance Several legacy skins were removed in the as the burden of supporting them became too heavy to bear Those in etc for skin dependent CSS etc for skin dependent JavaScript These can also be customised on a per user by etc This feature has led to a wide variety of user styles becoming that gallery is a good place to ending in php
Definition: skin.txt:62
wfGetDB
& wfGetDB( $db, $groups=array(), $wiki=false)
Get a Database object.
Definition: GlobalFunctions.php:3706
Maintenance\addOption
addOption( $name, $description, $required=false, $withArg=false, $shortName=false)
Add a parameter to the script.
Definition: Maintenance.php:169
RUN_MAINTENANCE_IF_MAIN
require_once RUN_MAINTENANCE_IF_MAIN
Definition: maintenance.txt:50
Maintenance
Abstract maintenance class for quickly writing and churning out maintenance scripts with minimal effo...
Definition: maintenance.txt:39
CleanupAncientTables\execute
execute()
Do the actual work.
Definition: cleanupAncientTables.php:40
CleanupAncientTables
Maintenance script to cleans up old database tables, dropping old indexes and fields.
Definition: cleanupAncientTables.php:32
array
the array() calling protocol came about after MediaWiki 1.4rc1.
List of Api Query prop modules.
CleanupAncientTables\__construct
__construct()
Default constructor.
Definition: cleanupAncientTables.php:34
as
This document is intended to provide useful advice for parties seeking to redistribute MediaWiki to end users It s targeted particularly at maintainers for Linux since it s been observed that distribution packages of MediaWiki often break We ve consistently had to recommend that users seeking support use official tarballs instead of their distribution s and this often solves whatever problem the user is having It would be nice if this could such as
Definition: distributors.txt:9
Maintenance\error
error( $err, $die=0)
Throw an error to the user.
Definition: Maintenance.php:333
Maintenance\output
output( $out, $channel=null)
Throw some output to the user.
Definition: Maintenance.php:314
Maintenance\hasOption
hasOption( $name)
Checks to see if a particular param exists.
Definition: Maintenance.php:181