r114345 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r114344‎ | r114345 | r114346 >
Date:05:03, 21 March 2012
Author:skizzerz
Status:fixme (Comments)
Tags:
Comment:
* Add $wgMaintenanceDebug global to configure the "Show debug information" box, which potentially reveals information such as environment variables
* The metadata.ini parser no longer fails outright when it encounters a script that does not exist on the server, it now just ignores that script (fixes "metadata.ini corrupted or missing" error on 1.18 and others)
* Modify some wording in checkImages and checkSyntax scripts
* Now supports three more scripts: cleanupSpam, clear_interwiki_cache, createAndPromote
* Bump version number to 2.1.0
Modified paths:
  • /trunk/extensions/Maintenance/Maintenance.i18n.php (modified) (history)
  • /trunk/extensions/Maintenance/Maintenance.php (modified) (history)
  • /trunk/extensions/Maintenance/Maintenance_body.php (modified) (history)
  • /trunk/extensions/Maintenance/metadata.ini (modified) (history)

Diff [purge]

Index: trunk/extensions/Maintenance/Maintenance.php
@@ -4,29 +4,41 @@
55 *
66 * @file
77 * @ingroup Extensions
8 - * @version 2.0.0
 8+ * @version 2.1.0
99 * @author Ryan Schmidt
1010 * @license http://www.gnu.org/copyleft/gpl.html GNU General Public License 2.0 or later
1111 * @link http://www.mediawiki.org/wiki/Extension:Maintenance Documentation
1212 */
1313
1414 if( !defined('MEDIAWIKI') ) {
15 - echo("This file is an extension to the MediaWiki software and is not a valid access point");
16 - die(1);
 15+ echo "This file is an extension to the MediaWiki software and is not a valid access point";
 16+ die( 1 );
1717 }
1818
 19+// !!!!!!!!!
 20+// BEGIN EXTENSION CONFIGURATION SECTION
 21+// !!!!!!!!!
 22+
 23+// Whether or not to show the "Output globals at the end of processing for debugging" checkbox
 24+// NOTE: enabling this can reveal system information such as environment variables
 25+$wgMaintenanceDebug = false;
 26+
 27+// !!!!!!!!!
 28+// END EXTENSION CONFIGURATION SECTION
 29+// !!!!!!!!!
 30+
1931 // Extension credits that will show up on Special:Version
2032 $wgExtensionCredits['specialpage'][] = array(
2133 'path' => __FILE__,
2234 'name' => 'Maintenance',
2335 'author' => 'Ryan Schmidt',
24 - 'version' => '2.0.0',
 36+ 'version' => '2.1.0',
2537 'descriptionmsg' => 'maintenance-desc',
2638 'url' => 'https://www.mediawiki.org/wiki/Extension:Maintenance',
2739 );
2840
2941 // Set up the new special page
30 -$dir = dirname(__FILE__) . '/';
 42+$dir = dirname( __FILE__ ) . '/';
3143 $wgExtensionMessagesFiles['Maintenance'] = $dir . 'Maintenance.i18n.php';
3244 $wgExtensionMessagesFiles['MaintenanceAlias'] = $dir . 'Maintenance.alias.php';
3345 $wgAutoloadClasses['SpecialMaintenance'] = $dir . 'Maintenance_body.php';
Index: trunk/extensions/Maintenance/metadata.ini
@@ -82,7 +82,15 @@
8383 enabled = 0
8484
8585 [cleanupSpam]
86 -enabled = 0
 86+arg = "hostname input"
 87+output[] = "found regex Found (.*) articles containing (.*)"
 88+output[] = "done string Done"
 89+output[] = "false string False match"
 90+output[] = "blanking string blanking"
 91+output[] = "reverting string reverting"
 92+output[] = "page regex (.*) \.\.\."
 93+error[] = "invalid regex Not a valid hostname specification: (.*)"
 94+error[] = "noid regex Internal error: no page for ID (.*)"
8795
8896 [cleanupTitles]
8997 enabled = 0
@@ -91,7 +99,8 @@
92100 enabled = 0
93101
94102 [clear_interwiki_cache]
95 -enabled = 0
 103+output[] = "db regex (.*)\.\.\."
 104+output[] = "done string done"
96105
97106 [clear_stats]
98107 enabled = 0
@@ -103,7 +112,14 @@
104113 enabled = 0
105114
106115 [createAndPromote]
107 -enabled = 0
 116+arg[] = "username input"
 117+arg[] = "password password"
 118+option = "bureaucrat check"
 119+output[] = "creating regex (.*): Creating and promoting User:(.*)\.\.\."
 120+output[] = "done string done."
 121+error[] = "invalid string invalid username."
 122+error[] = "exists string account exists."
 123+error[] = "password regex (.*)"
108124
109125 [deleteArchivedFiles]
110126 enabled = 0
Index: trunk/extensions/Maintenance/Maintenance_body.php
@@ -94,7 +94,7 @@
9595 }
9696
9797 private function makeForm( $type ) {
98 - global $wgOut, $wgUser;
 98+ global $wgOut, $wgUser, $wgMaintenanceDebug;
9999
100100 $this->setHeaders();
101101 $wgOut->addHTML( $wgUser->getSkin()->makeKnownLinkObj( $this->getTitle(), wfMsgHtml( 'maintenance-backlink' ) ). '<br />' );
@@ -112,30 +112,32 @@
113113 foreach( $options as $option ) {
114114 switch( $option['type'] ) {
115115 case 'check':
116 - $wgOut->addHTML( Xml::checkLabel( wfMsg( "maintenance-$type-option-" . $option['name'] ), 'wp' . ucfirst( $option['name'] ), 'wp' . ucfirst( $option['name'] ), $option['default'] ) . '<br /><br />' );
 116+ $wgOut->addHTML( Xml::checkLabel( wfMsg( "maintenance-$type-option-" . $option['name'] ), 'wp' . ucfirst( $option['name'] ), 'wp' . ucfirst( $option['name'] ), $option['default'] ) . '<br />' );
117117 break;
118118 case 'input':
119 - $wgOut->addHTML( Xml::inputLabel( wfMsg( "maintenance-$type-option-" . $option['name'] ), 'wp' . ucfirst( $option['name'] ), 'wp' . ucfirst( $option['name'] ), $option['size'], false, $option['attrib'] ) . '<br /><br />' );
 119+ $wgOut->addHTML( Xml::inputLabel( wfMsg( "maintenance-$type-option-" . $option['name'] ), 'wp' . ucfirst( $option['name'] ), 'wp' . ucfirst( $option['name'] ), $option['size'], false, $option['attrib'] ) . '<br />' );
120120 break;
121121 case 'password':
122 - $wgOut->addHTML( Xml::inputLabel( wfMsg( "maintenance-$type-option-" . $option['name'] ), 'wp' . ucfirst( $option['name'] ), 'wp' . ucfirst( $option['name'] ), $option['size'], false, array( 'type' => 'password' ) + $option['attrib'] ) . '<br /><br />' );
 122+ $wgOut->addHTML( Xml::inputLabel( wfMsg( "maintenance-$type-option-" . $option['name'] ), 'wp' . ucfirst( $option['name'] ), 'wp' . ucfirst( $option['name'] ), $option['size'], false, array( 'type' => 'password' ) + $option['attrib'] ) . '<br />' );
123123 break;
124124 case 'textarea':
125 - $wgOut->addHTML( wfMsg( "maintenance-$type-option-" . $option['name'] ) . '<textarea name="wp' . ucfirst( $option['name'] ) . '" rows="25" cols="80"></textarea><br /><br />');
 125+ $wgOut->addHTML( wfMsg( "maintenance-$type-option-" . $option['name'] ) . '<textarea name="wp' . ucfirst( $option['name'] ) . '" rows="25" cols="80"></textarea><br />');
126126 break;
127127 }
128128 }
129 - $wgOut->addHTML( Xml::checkLabel( wfMsg( 'maintenance-option-quiet' ), 'wpQuiet', 'wpQuiet' ) . '<br /><br />' );
130 - $wgOut->addHTML( Xml::checkLabel( wfMsg( 'maintenance-option-globals' ), 'wpGlobals', 'wpGlobals' ) . '<br /><br />' );
 129+ $wgOut->addHTML( Xml::checkLabel( wfMsg( 'maintenance-option-quiet' ), 'wpQuiet', 'wpQuiet' ) . '<br />' );
 130+ if( $wgMaintenanceDebug ) {
 131+ $wgOut->addHTML( Xml::checkLabel( wfMsg( 'maintenance-option-globals' ), 'wpGlobals', 'wpGlobals' ) . '<br />' );
 132+ }
131133 if( $this->metadata[$type]['batch'] ) {
132 - $wgOut->addHTML( Xml::inputLabel( wfMsg( 'maintenance-option-batch-size', $this->metadata[$type]['batch'] ), 'wpBatch-size', 'wpBatch-size' ) . '<br /><br />' );
 134+ $wgOut->addHTML( Xml::inputLabel( wfMsg( 'maintenance-option-batch-size', $this->metadata[$type]['batch'] ), 'wpBatch-size', 'wpBatch-size' ) . '<br />' );
133135 }
134136 $wgOut->addHTML( Xml::submitButton( wfMsg( 'maintenance-option-confirm' ), array( 'name' => 'wpConfirm' ) ) . '</form>' );
135137 return;
136138 }
137139
138140 private function executeScript( $type ) {
139 - global $wgOut, $wgRequest, $wgUser, $IP, $wgMaintenanceScripts;
 141+ global $wgOut, $wgRequest, $wgUser, $IP, $wgMaintenanceScripts, $wgMaintenanceDebug;
140142
141143 $this->setHeaders();
142144 $wgOut->addHTML( $wgUser->getSkin()->makeKnownLinkObj( $this->getTitle(), wfMsgHtml( 'maintenance-backlink' ) ). '<br />' );
@@ -329,7 +331,9 @@
330332 if( $needhax ) {
331333 unlink( $fname );
332334 }
333 - $script->globals();
 335+ if( $wgMaintenanceDebug ) {
 336+ $script->globals();
 337+ }
334338 $wgOut->addHTML( wfMsgExt( 'maintenance-output-success', array( 'escape' ), $this->type ) . "\n" );
335339 } catch( SpecialMaintenanceException $e ) {
336340 $wgOut->addHTML( wfMsgExt( 'maintenance-output-failure', array( 'escape' ), $this->type ) . "\n" );
@@ -358,7 +362,8 @@
359363
360364 //make sure that the script exists
361365 if( !file_exists( "$IP/maintenance/$script.php" ) && !array_key_exists( $script, $wgMaintenanceScripts ) ) {
362 - return false;
 366+ unset( $this->scripts[$i] ); //remove it from the list of scripts
 367+ continue;
363368 }
364369
365370 //parse options
Index: trunk/extensions/Maintenance/Maintenance.i18n.php
@@ -86,7 +86,7 @@
8787 'maintenance-checkBadRedirects-output-found' => "Found \$1 redirects.\nChecking for bad redirects...", #$1=number of redirects
8888 'maintenance-checkBadRedirects-output-footer' => "\nDone.",
8989 // checkImages
90 - 'maintenance-checkImages' => 'Use this form to see which images on your server are corrupted',
 90+ 'maintenance-checkImages' => 'Use this form to see which images on your wiki are corrupted',
9191 'maintenance-checkImages-desc' => 'Check images to see if they exist, are readable, etc',
9292 'maintenance-checkImages-output-noaccess' => '$1: not locally accessible', #$1=image name
9393 'maintenance-checkImages-output-missing' => '$1: missing', #$1=image name
@@ -100,7 +100,7 @@
101101 'maintenance-checkSyntax-option-with-extensions' => 'Also recurse the extensions folder',
102102 'maintenance-checkSyntax-option-path' => 'Specific path (file or directory) to check, either with absolute path or relative to the root of this MediaWiki installation',
103103 'maintenance-checkSyntax-option-list-file' => 'List of files or directories to check',
104 - 'maintenance-checkSyntax-option-modified' => 'Check only files that were modified (requires SVN command-line client)',
 104+ 'maintenance-checkSyntax-option-modified' => 'Check only files that were modified (requires svn command-line client)',
105105 'maintenance-checkSyntax-option-syntax-only' => 'Check for syntax validity only, skip code style warnings',
106106 'maintenance-checkSyntax-output-parsekit' => 'Checking syntax (using parsekit)',
107107 'maintenance-checkSyntax-output-phpl' => 'Checking syntax (using php -l, this can take a long time)',
@@ -135,9 +135,24 @@
136136 'maintenance-cleanupCaps-error-noneed' => '$wgCapitalLinks is on -- no need for caps links cleanup.',
137137 // cleanupImages
138138 // cleanupSpam
 139+ 'maintenance-cleanupSpam' => 'Use this form to revert spam edits that link to external sites',
 140+ 'maintenance-cleanupSpam-desc' => 'Clean up all spam from a given hostname',
 141+ 'maintenance-cleanupSpam-arg-hostname' => 'Hostname that was spamming',
 142+ 'maintenance-cleanupSpam-output-found' => 'Found $1 {{PLURAL:$1|articles|article}} containing $2', #$1=count, $2=hostname
 143+ 'maintenance-cleanupSpam-output-done' => '{{int:maintenance-generic-done}}',
 144+ 'maintenance-cleanupSpam-output-false' => 'False match',
 145+ 'maintenance-cleanupSpam-output-blanking' => 'blanking',
 146+ 'maintenance-cleanupSpam-output-reverting' => 'reverting',
 147+ 'maintenance-cleanupSpam-output-page' => '$1 ...', #$1=page name
 148+ 'maintenance-cleanupSpam-error-invalid' => 'Not a valid hostname specification: $1', #$1=hostname
 149+ 'maintenance-cleanupSpam-error-noid' => 'Internal error: no page for ID $1', #$1=page id
139150 // cleanupTitles
140151 // cleanupWatchlist
141152 // clear_interwiki_cache
 153+ 'maintenance-clear_interwiki_cache' => 'Use this form to completely clear the interwiki cache',
 154+ 'maintenance-clear_interwiki_cache-desc' => 'Clear all interwiki links for all languages from the cache',
 155+ 'maintenance-clear_interwiki_cache-done' => '{{int:maintenance-generic-done}}',
 156+ 'maintenance-clear_interwiki_cache-db' => '$1...', #$1=db name
142157 // clear_stats
143158 // convertLinks
144159 // convertUserOptions
@@ -145,6 +160,13 @@
146161 'maintenance-createAndPromote' => 'Use this form to create a new user and promote it to administrator. Check the bureaucrat box if you wish to promote to bureaucrat as well',
147162 'maintenance-createAndPromote-desc' => 'Create a user and promote to administrator status',
148163 'maintenance-createAndPromote-option-bureaucrat' => 'Promote user to bureaucrat status',
 164+ 'maintenance-createAndPromote-option-username' => '{{int:maintenance-generic-username}}',
 165+ 'maintenance-createAndPromote-option-password' => '{{int:maintenance-generic-password}}',
 166+ 'maintenance-createAndPromote-output-creating' => 'Creating and promoting User:$2...', #$1=wiki id, $2=username
 167+ 'maintenance-createAndPromote-output-done' => '{{int:maintenance-generic-done}}',
 168+ 'maintenance-createAndPromote-error-invalid' => '{{int:noname}}',
 169+ 'maintenance-createAndPromote-error-exists' => '{{int:userexists}}',
 170+ 'maintenance-createAndPromote-error-password' => 'An error was encountered with the password you entered: $1', #$1=password error
149171 // deleteArchivedFiles
150172 // deleteArchivedRevisions
151173 // deleteBatch

Follow-up revisions

RevisionCommit summaryAuthorDate
r114391r114345: Ignore some of the new keys for Translatewikiraymond18:56, 21 March 2012

Comments

#Comment by Nikerabbit (talk | contribs)   14:55, 21 March 2012

Please add message documentation for the newly added messages. Thanks.

#Comment by Skizzerz (talk | contribs)   15:54, 21 March 2012

Please don't use canned replies without stating a good way as to how to go about doing this. Thanks.

In all seriousness, I have no idea when/what half of the messages are or do. I simply look through the maintenance scripts, see if the output is normal output or an error, and come up with a way to match it. The key names are based on the content of the message with some other metadata so that the extension knows which message to use. If you want thorough documentation for the messages used, you aren't going to find it from me as I simply do not have the time to understand the intricacies of every single maintenance script shipped with core to make the message make any more sense than what is already written in the message itself.

#Comment by Nikerabbit (talk | contribs)   15:57, 21 March 2012

It's not about the key, it's about the content. Translators must understand what they are translating. And they are not going to read those #comments in the i18n file, but the documentation under qqq language code. For the very least each message should be documented to say it is for a maintenance script output and document which messages appear together.

#Comment by 😂 (talk | contribs)   17:28, 21 March 2012

Maybe we could get rid of this entire abomination and it would be a non-issue.

#Comment by Nikerabbit (talk | contribs)   07:49, 24 March 2012

There are multiple requests for message documentation in translatewiki.net: http://translatewiki.net/wiki/Translating_talk:MediaWiki

Please add message documentation (ask help if needed) or I will revert this commit or drop Maintenance extension from translatewiki.net

#Comment by Skizzerz (talk | contribs)   21:25, 24 March 2012

I'll get to it sometime next week. Be warned that the "documentation" is going to be very bare-bones: only listing what the $params mean, whether a message describes input or output, and what the general purpose of the maintenance script is.

Status & tagging log