From f7c4c52ba030894ea3bc0d912300f43a60f315a9 Mon Sep 17 00:00:00 2001 From: Alexandre Emsenhuber Date: Mon, 25 Jun 2012 21:54:41 +0200 Subject: [PATCH] Improve documentation of maintenance scripts. Change-Id: I1c911eb0fd6108fdee0b4e96363d87b926aba396 --- maintenance/cleanupAncientTables.php | 6 ++++ maintenance/cleanupCaps.php | 7 ++++- maintenance/cleanupImages.php | 9 ++++-- maintenance/cleanupRemovedModules.php | 9 ++++-- maintenance/cleanupSpam.php | 7 ++++- maintenance/cleanupTable.inc | 7 ++++- maintenance/cleanupTitles.php | 7 ++++- maintenance/cleanupUploadStash.php | 6 ++++ maintenance/cleanupWatchlist.php | 9 ++++-- maintenance/clear_interwiki_cache.php | 8 +++-- maintenance/clear_stats.php | 7 ++++- maintenance/compareParsers.php | 45 ++++++++++++++++----------- 12 files changed, 95 insertions(+), 32 deletions(-) diff --git a/maintenance/cleanupAncientTables.php b/maintenance/cleanupAncientTables.php index 56d76987b7..d449d6c591 100644 --- a/maintenance/cleanupAncientTables.php +++ b/maintenance/cleanupAncientTables.php @@ -23,6 +23,12 @@ require_once( dirname( __FILE__ ) . '/Maintenance.php' ); +/** + * Maintenance script to cleans up old database tables, dropping old indexes + * and fields. + * + * @ingroup Maintenance + */ class CleanupAncientTables extends Maintenance { public function __construct() { diff --git a/maintenance/cleanupCaps.php b/maintenance/cleanupCaps.php index 6f8e180c89..b61f6ff4ef 100644 --- a/maintenance/cleanupCaps.php +++ b/maintenance/cleanupCaps.php @@ -1,6 +1,6 @@ + * Copyright © 2005-2006 Brion Vibber * http://www.mediawiki.org/ * * This program is free software; you can redistribute it and/or modify @@ -31,6 +31,11 @@ require_once( dirname( __FILE__ ) . '/cleanupTable.inc' ); +/** + * Maintenance script to clean up broken, unparseable upload filenames. + * + * @ingroup Maintenance + */ class ImageCleanup extends TableCleanup { protected $defaultParams = array( 'table' => 'image', diff --git a/maintenance/cleanupRemovedModules.php b/maintenance/cleanupRemovedModules.php index fb8afd2db6..b339bfcdcf 100644 --- a/maintenance/cleanupRemovedModules.php +++ b/maintenance/cleanupRemovedModules.php @@ -1,7 +1,6 @@ 'page', diff --git a/maintenance/cleanupTitles.php b/maintenance/cleanupTitles.php index 4fc6415e51..a2dc3a3c60 100644 --- a/maintenance/cleanupTitles.php +++ b/maintenance/cleanupTitles.php @@ -1,6 +1,6 @@ + * Copyright © 2005,2006 Brion Vibber * http://www.mediawiki.org/ * * This program is free software; you can redistribute it and/or modify @@ -31,6 +31,11 @@ require_once( dirname( __FILE__ ) . '/cleanupTable.inc' ); +/** + * Maintenance script to remove broken, unparseable titles in the watchlist table. + * + * @ingroup Maintenance + */ class WatchlistCleanup extends TableCleanup { protected $defaultParams = array( 'table' => 'watchlist', diff --git a/maintenance/clear_interwiki_cache.php b/maintenance/clear_interwiki_cache.php index 953bd4ce43..638a475c64 100644 --- a/maintenance/clear_interwiki_cache.php +++ b/maintenance/clear_interwiki_cache.php @@ -1,7 +1,6 @@ hasOption('save-failed') ) { $this->saveFailed = $this->getOption('save-failed'); } - + $this->stripParametersEnabled = $this->hasOption( 'strip-parameters' ); $this->showParsedOutput = $this->hasOption( 'show-parsed-output' ); - + $this->showDiff = $this->hasOption( 'show-diff' ); if ( $this->showDiff ) { $bin = $this->getOption( 'diff-bin', getenv( 'DIFF' ) ); @@ -63,10 +70,10 @@ class CompareParsers extends DumpIterator { $wgDiff = $bin; } } - - $user = new User(); + + $user = new User(); $this->options = ParserOptions::newFromUser( $user ); - + if ( $this->hasOption( 'tidy' ) ) { global $wgUseTidy; if ( !$wgUseTidy ) { @@ -74,46 +81,46 @@ class CompareParsers extends DumpIterator { } $this->options->setTidy( true ); } - + $this->failed = 0; } - - public function conclusions() { + + public function conclusions() { $this->error( "{$this->failed} failed revisions out of {$this->count}" ); if ($this->count > 0) $this->output( " (" . ( $this->failed / $this->count ) . "%)\n" ); } - + function stripParameters( $text ) { if ( !$this->stripParametersEnabled ) { return $text; } return preg_replace( '/(]+>/', '$1>', $text ); } - + /** * Callback function for each revision, parse with both parsers and compare * @param $rev Revision */ public function processRevision( $rev ) { $title = $rev->getTitle(); - + $parser1Name = $this->getOption( 'parser1' ); $parser2Name = $this->getOption( 'parser2' ); - + self::checkParserLocally( $parser1Name ); self::checkParserLocally( $parser2Name ); - + $parser1 = new $parser1Name(); $parser2 = new $parser2Name(); - + $output1 = $parser1->parse( $rev->getText(), $title, $this->options ); $output2 = $parser2->parse( $rev->getText(), $title, $this->options ); if ( $output1->getText() != $output2->getText() ) { $this->failed++; $this->error( "Parsing for {$title->getPrefixedText()} differs\n" ); - + if ( $this->saveFailed ) { file_put_contents( $this->saveFailed . '/' . rawurlencode( $title->getPrefixedText() ) . ".txt", $rev->getText()); } @@ -127,7 +134,7 @@ class CompareParsers extends DumpIterator { } } } - + private static function checkParserLocally( $parserName ) { /* Look for the parser in a file appropiately named in the current folder */ if ( !class_exists( $parserName ) && file_exists( "$parserName.php" ) ) { -- 2.20.1