r41630 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r41629‎ | r41630 | r41631 >
Date:00:33, 4 October 2008
Author:siebrand
Status:old (Comments)
Tags:
Comment:
* Add functionality of extension Nuke to core. Messages for other languages will be added in a next commit.
* Update Translate
Modified paths:
  • /trunk/extensions/Translate/aliases.txt (modified) (history)
  • /trunk/extensions/Translate/groups/MediaWikiExtensions.php (modified) (history)
  • /trunk/extensions/Translate/groups/mediawiki-defines.txt (modified) (history)
  • /trunk/phase3/RELEASE-NOTES (modified) (history)
  • /trunk/phase3/includes/AutoLoader.php (modified) (history)
  • /trunk/phase3/includes/DefaultSettings.php (modified) (history)
  • /trunk/phase3/includes/SpecialPage.php (modified) (history)
  • /trunk/phase3/includes/specials/SpecialNuke.php (added) (history)
  • /trunk/phase3/languages/messages/MessagesAr.php (modified) (history)
  • /trunk/phase3/languages/messages/MessagesArz.php (modified) (history)
  • /trunk/phase3/languages/messages/MessagesDe.php (modified) (history)
  • /trunk/phase3/languages/messages/MessagesEn.php (modified) (history)
  • /trunk/phase3/languages/messages/MessagesHe.php (modified) (history)
  • /trunk/phase3/languages/messages/MessagesNds_nl.php (modified) (history)
  • /trunk/phase3/languages/messages/MessagesNl.php (modified) (history)
  • /trunk/phase3/languages/messages/MessagesNo.php (modified) (history)
  • /trunk/phase3/maintenance/language/messages.inc (modified) (history)

Diff [purge]

Index: trunk/phase3/maintenance/language/messages.inc
@@ -2759,6 +2759,17 @@
27602760 'external_images' => array(
27612761 'external_image_whitelist',
27622762 ),
 2763+ 'special-nuke' => array(
 2764+ 'nuke',
 2765+ 'nuke-nopages',
 2766+ 'nuke-list',
 2767+ 'nuke-defaultreason',
 2768+ 'nuke-tools',
 2769+ 'nuke-submit-user',
 2770+ 'nuke-submit-delete',
 2771+ 'right-nuke',
 2772+ ),
 2773+
27632774 );
27642775
27652776 /** Comments for each block */
@@ -2953,6 +2964,7 @@
29542965 'special-specialpages' => 'Special:SpecialPages',
29552966 'special-blank' => 'Special:BlankPage',
29562967 'external_images' => 'External image whitelist',
 2968+ 'special-nuke' => 'Special:Nuke',
29572969 );
29582970
29592971 /** Short comments for standalone messages */
Index: trunk/phase3/includes/AutoLoader.php
@@ -477,6 +477,7 @@
478478 'SpecialBookSources' => 'includes/specials/SpecialBooksources.php',
479479 'SpecialListGroupRights' => 'includes/specials/SpecialListgrouprights.php',
480480 'SpecialMostlinkedtemplates' => 'includes/specials/SpecialMostlinkedtemplates.php',
 481+ 'SpecialNuke' => 'includes/specials/SpecialNuke.php',
481482 'SpecialPrefixindex' => 'includes/specials/SpecialPrefixindex.php',
482483 'SpecialRandomredirect' => 'includes/specials/SpecialRandomredirect.php',
483484 'SpecialRecentchanges' => 'includes/specials/SpecialRecentchanges.php',
Index: trunk/phase3/includes/DefaultSettings.php
@@ -1183,6 +1183,8 @@
11841184 $wgGroupPermissions['sysop']['apihighlimits'] = true;
11851185 $wgGroupPermissions['sysop']['browsearchive'] = true;
11861186 $wgGroupPermissions['sysop']['noratelimit'] = true;
 1187+$wgGroupPermissions['sysop']['nuke'] = true;
 1188+
11871189 #$wgGroupPermissions['sysop']['mergehistory'] = true;
11881190
11891191 // Permission to change users' group assignments
@@ -2850,6 +2852,7 @@
28512853 'Export' => 'pagetools',
28522854 'Import' => 'pagetools',
28532855 'Whatlinkshere' => 'pagetools',
 2856+ 'Nuke' => 'pagetools',
28542857
28552858 'Statistics' => 'wiki',
28562859 'Version' => 'wiki',
Index: trunk/phase3/includes/specials/SpecialNuke.php
@@ -0,0 +1,159 @@
 2+<?php
 3+/**
 4+ * @file
 5+ * @ingroup SpecialPage
 6+ *
 7+ * @author Brion Vibber
 8+ * @copyright Copyright © 2005-2008, Brion Vibber
 9+ * @license http://www.gnu.org/copyleft/gpl.html GNU General Public License 2.0 or later
 10+ */
 11+
 12+/**
 13+ * implements Special:Nuke
 14+ */
 15+
 16+class SpecialNuke extends SpecialPage {
 17+ function __construct() {
 18+ parent::__construct( 'Nuke', 'nuke' );
 19+ }
 20+
 21+ function execute( $par ){
 22+ global $wgUser, $wgRequest;
 23+
 24+ if( !$this->userCanExecute( $wgUser ) ){
 25+ $this->displayRestrictionError();
 26+ return;
 27+ }
 28+
 29+ $this->setHeaders();
 30+ $this->outputHeader();
 31+
 32+ $target = $wgRequest->getText( 'target', $par );
 33+ $reason = $wgRequest->getText( 'wpReason',
 34+ wfMsgForContent( 'nuke-defaultreason', $target ) );
 35+ $posted = $wgRequest->wasPosted() &&
 36+ $wgUser->matchEditToken( $wgRequest->getVal( 'wpEditToken' ) );
 37+ if( $posted ) {
 38+ $pages = $wgRequest->getArray( 'pages' );
 39+ if( $pages ) {
 40+ return $this->doDelete( $pages, $reason );
 41+ }
 42+ }
 43+ if( $target != '' ) {
 44+ $this->listForm( $target, $reason );
 45+ } else {
 46+ $this->promptForm();
 47+ }
 48+ }
 49+
 50+ function promptForm() {
 51+ global $wgUser, $wgOut;
 52+ $sk =& $wgUser->getSkin();
 53+
 54+ $nuke = Title::makeTitle( NS_SPECIAL, 'Nuke' );
 55+ $submit = Xml::element( 'input', array( 'type' => 'submit', 'value' => wfMsgHtml( 'nuke-submit-user' ) ) );
 56+
 57+ $wgOut->addWikiText( wfMsg( 'nuke-tools' ) );
 58+ $wgOut->addHTML( Xml::element( 'form', array(
 59+ 'action' => $nuke->getLocalURL( 'action=submit' ),
 60+ 'method' => 'post' ),
 61+ null ) .
 62+ Xml::element( 'input', array(
 63+ 'type' => 'text',
 64+ 'size' => 40,
 65+ 'name' => 'target' ) ) .
 66+ "\n$submit\n" );
 67+
 68+ $wgOut->addHTML( "</form>" );
 69+ }
 70+
 71+ function listForm( $username, $reason ) {
 72+ global $wgUser, $wgOut, $wgLang;
 73+
 74+ $pages = $this->getNewPages( $username );
 75+ $escapedName = wfEscapeWikiText( $username );
 76+ if( count( $pages ) == 0 ) {
 77+ $wgOut->addWikiText( wfMsg( 'nuke-nopages', $escapedName ) );
 78+ return $this->promptForm();
 79+ }
 80+ $wgOut->addWikiText( wfMsg( 'nuke-list', $escapedName ) );
 81+
 82+ $nuke = $this->getTitle();
 83+ $submit = Xml::element( 'input', array( 'type' => 'submit', 'value' => wfMsgHtml( 'nuke-submit-delete' ) ) );
 84+
 85+ $wgOut->addHTML( Xml::element( 'form', array(
 86+ 'action' => $nuke->getLocalURL( 'action=delete' ),
 87+ 'method' => 'post' ),
 88+ null ) .
 89+ "\n<div>" .
 90+ wfMsgHtml( 'deletecomment' ) . ' ' .
 91+ Xml::element( 'input', array(
 92+ 'name' => 'wpReason',
 93+ 'value' => $reason,
 94+ 'size' => 60 ) ) .
 95+ "</div><br />" .
 96+ $submit .
 97+ Xml::element( 'input', array(
 98+ 'type' => 'hidden',
 99+ 'name' => 'wpEditToken',
 100+ 'value' => $wgUser->editToken() ) ) .
 101+ "\n<ul>\n" );
 102+
 103+ $sk =& $wgUser->getSkin();
 104+ foreach( $pages as $info ) {
 105+ list( $title, $edits ) = $info;
 106+ $image = $title->getNamespace() == NS_IMAGE ? wfLocalFile( $title ) : false;
 107+ $thumb = $image && $image->exists() ? $image->getThumbnail( 120, 120 ) : false;
 108+
 109+ $wgOut->addHTML( '<li>' .
 110+ Xml::element( 'input', array(
 111+ 'type' => 'checkbox',
 112+ 'name' => "pages[]",
 113+ 'value' => $title->getPrefixedDbKey(),
 114+ 'checked' => 'checked' ) ) .
 115+ '&nbsp;' .
 116+ ( $thumb ? $thumb->toHtml( array( 'desc-link' => true ) ) : '' ) .
 117+ $sk->makeKnownLinkObj( $title ) .
 118+ '&nbsp;(' .
 119+ $sk->makeKnownLinkObj( $title, wfMsgExt( 'nchanges', array( 'parsemag' ), $wgLang->formatNum( $edits ) ), 'action=history' ) .
 120+ ")</li>\n" );
 121+ }
 122+ $wgOut->addHTML( "</ul>\n$submit</form>" );
 123+ }
 124+
 125+ function getNewPages( $username ) {
 126+ $dbr = wfGetDB( DB_SLAVE );
 127+ $result = $dbr->select( 'recentchanges',
 128+ array( 'rc_namespace', 'rc_title', 'rc_timestamp', 'COUNT(*) AS edits' ),
 129+ array(
 130+ 'rc_user_text' => $username,
 131+ '(rc_new = 1) OR (rc_log_type = "upload" AND rc_log_action = "upload")'
 132+ ),
 133+ __METHOD__,
 134+ array(
 135+ 'ORDER BY' => 'rc_timestamp DESC',
 136+ 'GROUP BY' => 'rc_namespace, rc_title'
 137+ )
 138+ );
 139+ $pages = array();
 140+ while( $row = $dbr->fetchObject( $result ) ) {
 141+ $pages[] = array( Title::makeTitle( $row->rc_namespace, $row->rc_title ), $row->edits );
 142+ }
 143+ $dbr->freeResult( $result );
 144+ return $pages;
 145+ }
 146+
 147+ function doDelete( $pages, $reason ) {
 148+ foreach( $pages as $page ) {
 149+ $title = Title::newFromUrl( $page );
 150+ $file = $title->getNamespace() == NS_IMAGE ? wfLocalFile( $title ) : false;
 151+ if ( $file ) {
 152+ $oldimage = null; // Must be passed by reference
 153+ FileDeleteForm::doDelete( $title, $file, $oldimage, $reason, false );
 154+ } else {
 155+ $article = new Article( $title );
 156+ $article->doDelete( $reason );
 157+ }
 158+ }
 159+ }
 160+}
Property changes on: trunk/phase3/includes/specials/SpecialNuke.php
___________________________________________________________________
Added: svn:mergeinfo
Added: svn:eol-style
1161 + native
Index: trunk/phase3/includes/SpecialPage.php
@@ -164,6 +164,7 @@
165165 'Listadmins' => array( 'SpecialRedirectToSpecial', 'Listadmins', 'Listusers', 'sysop' ),
166166 'MergeHistory' => array( 'SpecialPage', 'MergeHistory', 'mergehistory' ),
167167 'Listbots' => array( 'SpecialRedirectToSpecial', 'Listbots', 'Listusers', 'bot' ),
 168+ 'Nuke' => 'SpecialNuke',
168169 );
169170
170171 static public $mAliases;
Index: trunk/phase3/languages/messages/MessagesHe.php
@@ -283,6 +283,7 @@
284284 'Blankpage' => array( 'דף_ריק' ),
285285 'LinkSearch' => array( 'חיפוש_קישורים_חיצוניים' ),
286286 'DeletedContributions' => array( 'תרומות_מחוקות' ),
 287+ 'Nuke' => array( 'מחיקה_מרובה' ),
287288 );
288289
289290 $namespaceNames = array(
Index: trunk/phase3/languages/messages/MessagesAr.php
@@ -367,6 +367,7 @@
368368 'Blankpage' => array( 'صفحة_فارغة' ),
369369 'LinkSearch' => array( 'بحث_الوصلات' ),
370370 'DeletedContributions' => array( 'مساهمات_محذوفة' ),
 371+ 'Nuke' => array( 'حذف_كمي' ),
371372 );
372373
373374 $imageFiles = array(
Index: trunk/phase3/languages/messages/MessagesNds_nl.php
@@ -251,6 +251,7 @@
252252 'Withoutinterwiki' => array( 'Gien_interwiki' ),
253253 'LinkSearch' => array( 'Verwiezingen_zeuken' ),
254254 'DeletedContributions' => array( 'Vort-ehaolen gebrukersbiedragen' ),
 255+ 'Nuke' => array( 'Massaal_vortdoon' ),
255256 );
256257
257258 $linkTrail = '/^([a-zäöüïëéèà]+)(.*)$/sDu';
Index: trunk/phase3/languages/messages/MessagesEn.php
@@ -439,6 +439,7 @@
440440 'Blankpage' => array( 'BlankPage' ),
441441 'LinkSearch' => array( 'LinkSearch' ),
442442 'DeletedContributions' => array( 'DeletedContributions' ),
 443+ 'Nuke' => array( 'Nuke' ),
443444 );
444445
445446 /**
@@ -3670,4 +3671,16 @@
36713672
36723673 #Put all regex fragments above this line. Leave this line exactly as it is</pre>',
36733674
 3675+# Special:Nuke
 3676+'nuke' => 'Mass delete',
 3677+'nuke-nopages' => 'No new pages by [[Special:Contributions/$1|$1]] in recent changes.',
 3678+'nuke-list' => 'The following pages were recently created by [[Special:Contributions/$1|$1]];
 3679+put in a comment and hit the button to delete them.',
 3680+'nuke-defaultreason' => 'Mass removal of pages added by $1',
 3681+'nuke-tools' => 'This tool allows for mass deletions of pages recently added by a given user or IP.
 3682+Input the username or IP to get a list of pages to delete.',
 3683+'nuke-submit-user' => 'Go',
 3684+'nuke-submit-delete' => 'Delete selected',
 3685+'right-nuke' => 'Mass delete pages',
 3686+
36743687 );
Index: trunk/phase3/languages/messages/MessagesNo.php
@@ -163,6 +163,7 @@
164164 'Blankpage' => array( 'Blank side' ),
165165 'LinkSearch' => array( 'Lenkesøk' ),
166166 'DeletedContributions' => array( 'Slettede bidrag' ),
 167+ 'Nuke' => array( 'Massesletting' ),
167168 );
168169
169170 $messages = array(
Index: trunk/phase3/languages/messages/MessagesArz.php
@@ -264,6 +264,7 @@
265265 'Blankpage' => array( 'صفحة_فارغة' ),
266266 'LinkSearch' => array( 'بحث_الوصلات' ),
267267 'DeletedContributions' => array( 'مساهمات_محذوفة' ),
 268+ 'Nuke' => array( 'حذف_كمى' ),
268269 );
269270
270271 $messages = array(
Index: trunk/phase3/languages/messages/MessagesNl.php
@@ -278,6 +278,7 @@
279279 'ListUserRestrictions' => array( 'Gebruikersbeperkingen' ),
280280 'RemoveRestrictions' => array( 'BeperkingenVerwijderen' ),
281281 'RestrictUser' => array( 'GebruikerBeperken' ),
 282+ 'Nuke' => array( 'MassaalVerwijderen' ),
282283 );
283284
284285 $linkTrail = '/^([a-zäöüïëéèà]+)(.*)$/sDu';
Index: trunk/phase3/languages/messages/MessagesDe.php
@@ -157,6 +157,7 @@
158158 'Blankpage' => array( 'Leerseite' ),
159159 'LinkSearch' => array( 'Weblink-Suche' ),
160160 'DeletedContributions' => array( 'Gelöschte Beiträge' ),
 161+ 'Nuke' => array( 'Massenlöschung' ),
161162 );
162163
163164 $datePreferences = array(
Index: trunk/phase3/RELEASE-NOTES
@@ -58,6 +58,7 @@
5959 * Special:LinkSearch to search for external links (was extension LinkSearch)
6060 * RenderHash
6161 * NoMoveUserPages
 62+* Special:Nuke to mass delete all pages created by a user
6263
6364 === New features in 1.14 ===
6465
Index: trunk/extensions/Translate/groups/MediaWikiExtensions.php
@@ -369,7 +369,6 @@
370370 'ext-usernameblacklist',
371371 'ext-checkuser', // sysop or higher only
372372 'ext-globalblocking',
373 - 'ext-nuke',
374373 'ext-oversight',
375374 'ext-renameuser',
376375 'ext-assertedit', // bots
Index: trunk/extensions/Translate/groups/mediawiki-defines.txt
@@ -455,9 +455,6 @@
456456
457457 No Move Userpages
458458
459 -Nuke
460 -file = Nuke/SpecialNuke.i18n.php
461 -
462459 OAI-PMH repository
463460 id = ext-oai
464461 file = OAI/OAIRepo.i18n.php
Index: trunk/extensions/Translate/aliases.txt
@@ -151,9 +151,6 @@
152152 News channel
153153 file = NewsChannel/NewsChannel.alias.php
154154
155 -Nuke
156 -file = Nuke/SpecialNuke.alias.php
157 -
158155 Oversight
159156 file = Oversight/HideRevision.alias.php
160157

Follow-up revisions

RevisionCommit summaryAuthorDate
r41632* Localisation updates for core messages from Betawiki. Contains follow up on...siebrand00:46, 4 October 2008
r42117Back out r41630 -- merging of Nuke extension to core...brion21:35, 15 October 2008

Comments

#Comment by Tim Starling (talk | contribs)   04:17, 10 October 2008

I don't understand why this would be a good idea now when it wasn't when the extension was written. What has changed?

#Comment by Siebrand (talk | contribs)   09:11, 10 October 2008

Nothing really, aside from a List of extensions to be merged to the core.

#Comment by Tim Starling (talk | contribs)   14:24, 11 October 2008

You mean some random guy created a wiki page and made a whole lot of questionable decisions on it? That's what's changed?

No reversibility, no error handling, 150 lines of code, looks like about 10 minutes' work. I'm not sure this should be in the core as-is.

#Comment by Siebrand (talk | contribs)   16:49, 11 October 2008

Hmm, well, by now both you and Brion have edited that page. There is no talk saying "this is a fundamentally bad idea". You bear more responsibility for the MediaWiki development than I do, are more skilled, and have a better overview. I thought it a nice feature to have in core, I could add it, and I did it. We are all able to revert, so if you fundamentally disagree, please feel free to do so.

#Comment by Brion VIBBER (talk | contribs)   21:35, 15 October 2008

Reverted for now in r42117. We'll consider re-merging in future when it's all purty and has reversible tools, better accountability etc.

Status & tagging log