From 32515c4bda22850c614ee7f063a776b5c6e032c4 Mon Sep 17 00:00:00 2001 From: Alexandre Emsenhuber Date: Tue, 17 Jul 2012 07:40:40 +0200 Subject: [PATCH] Improve documentation of maintenance scripts. Change-Id: If0af9922ede902c2c6f18b627d5810f3e888c944 --- maintenance/deleteBatch.php | 2 +- maintenance/edit.php | 1 + maintenance/fixSlaveDesync.php | 1 + maintenance/generateSitemap.php | 7 ++++++- maintenance/getLagTimes.php | 8 +++++++ maintenance/getSlaveServer.php | 8 ++++++- maintenance/getText.php | 9 +++++++- maintenance/importDump.php | 6 +++++- maintenance/importImages.inc | 2 +- maintenance/importImages.php | 5 ++--- maintenance/importSiteScripts.php | 35 ++++++++++++++++++------------- maintenance/importTextFile.php | 4 +--- maintenance/initStats.php | 7 ++++++- maintenance/install.php | 10 +++++++-- 14 files changed, 75 insertions(+), 30 deletions(-) diff --git a/maintenance/deleteBatch.php b/maintenance/deleteBatch.php index 2a99fa1866..6860a5afa4 100644 --- a/maintenance/deleteBatch.php +++ b/maintenance/deleteBatch.php @@ -1,6 +1,6 @@ ] [-r ] [-i ] [listfile] * where * [listfile] is a file where each line contains the title of a page to be diff --git a/maintenance/edit.php b/maintenance/edit.php index 211dc4edd1..13b3c49181 100644 --- a/maintenance/edit.php +++ b/maintenance/edit.php @@ -17,6 +17,7 @@ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * http://www.gnu.org/copyleft/gpl.html * + * @file * @ingroup Maintenance */ diff --git a/maintenance/fixSlaveDesync.php b/maintenance/fixSlaveDesync.php index de6f652137..126eed2524 100644 --- a/maintenance/fixSlaveDesync.php +++ b/maintenance/fixSlaveDesync.php @@ -17,6 +17,7 @@ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * http://www.gnu.org/copyleft/gpl.html * + * @file * @ingroup Maintenance */ diff --git a/maintenance/generateSitemap.php b/maintenance/generateSitemap.php index 7e83d5f659..a81e3d9e91 100644 --- a/maintenance/generateSitemap.php +++ b/maintenance/generateSitemap.php @@ -1,6 +1,6 @@ and * Brion Vibber @@ -28,6 +28,11 @@ require_once( dirname( __FILE__ ) . '/Maintenance.php' ); +/** + * Maintenance script that generates a sitemap for the site. + * + * @ingroup Maintenance + */ class GenerateSitemap extends Maintenance { const GS_MAIN = -2; const GS_TALK = -1; diff --git a/maintenance/getLagTimes.php b/maintenance/getLagTimes.php index 0322fa2dc2..c47c61e4be 100644 --- a/maintenance/getLagTimes.php +++ b/maintenance/getLagTimes.php @@ -1,5 +1,7 @@ + * Import XML dump files into the current wiki. + * + * Copyright © 2005 Brion Vibber * http://www.mediawiki.org/ * * This program is free software; you can redistribute it and/or modify @@ -25,6 +27,8 @@ require_once( dirname( __FILE__ ) . '/Maintenance.php' ); /** + * Maintenance script that imports XML dump files into the current wiki. + * * @ingroup Maintenance */ class BackupReader extends Maintenance { diff --git a/maintenance/importImages.inc b/maintenance/importImages.inc index 5eb68f20b3..ac5d14432b 100644 --- a/maintenance/importImages.inc +++ b/maintenance/importImages.inc @@ -1,6 +1,6 @@ addArg( 'index', 'index.php base url' ); $this->addOption( 'username', 'User name of the script importer' ); } - + public function execute() { global $wgUser; $user = User::newFromName( $this->getOption( 'username', 'ScriptImporter' ) ); $wgUser = $user; - + $baseUrl = $this->getArg( 1 ); $pageList = $this->fetchScriptList(); $this->output( 'Importing ' . count( $pageList ) . " pages\n" ); - + foreach ( $pageList as $page ) { $title = Title::makeTitleSafe( NS_MEDIAWIKI, $page ); if ( !$title ) { @@ -51,34 +56,34 @@ class ImportSiteScripts extends Maintenance { } $this->output( "Importing $page\n" ); - $url = wfAppendQuery( $baseUrl, array( - 'action' => 'raw', + $url = wfAppendQuery( $baseUrl, array( + 'action' => 'raw', 'title' => "MediaWiki:{$page}" ) ); $text = Http::get( $url ); $wikiPage = WikiPage::factory( $title ); $wikiPage->doEdit( $text, "Importing from $url", 0, false, $user ); } - + } - + protected function fetchScriptList() { - $data = array( + $data = array( 'action' => 'query', 'format' => 'php',//'json', 'list' => 'allpages', 'apnamespace' => '8', - 'aplimit' => '500', + 'aplimit' => '500', ); $baseUrl = $this->getArg( 0 ); $pages = array(); - + do { $url = wfAppendQuery( $baseUrl, $data ); $strResult = Http::get( $url ); //$result = FormatJson::decode( $strResult ); // Still broken $result = unserialize( $strResult ); - + if ( !empty( $result['query']['allpages'] ) ) { foreach ( $result['query']['allpages'] as $page ) { if ( substr( $page['title'], -3 ) === '.js' ) { @@ -92,9 +97,9 @@ class ImportSiteScripts extends Maintenance { $this->output( "Fetching new batch from {$data['apfrom']}\n" ); } } while ( isset( $result['query-continue'] ) ); - + return $pages; - + } } diff --git a/maintenance/importTextFile.php b/maintenance/importTextFile.php index ec9ff001ad..5623fb06c2 100644 --- a/maintenance/importTextFile.php +++ b/maintenance/importTextFile.php @@ -1,8 +1,6 @@