r65546 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r65545‎ | r65546 | r65547 >
Date:16:35, 26 April 2010
Author:churchofemacs
Status:ok (Comments)
Tags:
Comment:
fixing bug 20186: allow filtering SpecialContributions for RevisionDeleted edits. See also bug 20186 comment 22
Modified paths:
  • /trunk/phase3/RELEASE-NOTES (modified) (history)
  • /trunk/phase3/includes/specials/SpecialContributions.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/specials/SpecialContributions.php
@@ -64,6 +64,8 @@
6565 $this->opts['namespace'] = '';
6666 }
6767
 68+ $this->opts['deletedOnly'] = ( $wgRequest->getVal( 'deletedOnly' ) == '1' );
 69+
6870 $this->opts['tagfilter'] = (string) $wgRequest->getVal( 'tagfilter' );
6971
7072 // Allows reverts to have the bot flag in recent changes. It is just here to
@@ -93,7 +95,8 @@
9496
9597 $wgOut->addHTML( $this->getForm() );
9698
97 - $pager = new ContribsPager( $target, $this->opts['namespace'], $this->opts['year'], $this->opts['month'] );
 99+ $pager = new ContribsPager( $target, $this->opts['namespace'], $this->opts['year'],
 100+ $this->opts['month'], false, $this->opts['deletedOnly'] );
98101 if( !$pager->getNumRows() ) {
99102 $wgOut->addWikiMsg( 'nocontribs', $target );
100103 } else {
@@ -296,9 +299,11 @@
297300 }
298301
299302 $f = Xml::openElement( 'form', array( 'method' => 'get', 'action' => $wgScript ) );
300 - # Add hidden params for tracking
 303+
 304+ # Add hidden params for tracking except for parameters in $skipParameters
 305+ $skipParameters = array( 'namespace', 'deletedOnly', 'target', 'contribs', 'year', 'month' );
301306 foreach ( $this->opts as $name => $value ) {
302 - if( in_array( $name, array( 'namespace', 'target', 'contribs', 'year', 'month' ) ) ) {
 307+ if( in_array( $name, $skipParameters ) ) {
303308 continue;
304309 }
305310 $f .= "\t" . Xml::hidden( $name, $value ) . "\n";
@@ -320,6 +325,8 @@
321326 Xml::label( wfMsg( 'namespace' ), 'namespace' ) . ' ' .
322327 Xml::namespaceSelector( $this->opts['namespace'], '' ) .
323328 '</span>' .
 329+ Xml::checkLabel( wfMsg( 'history-show-deleted' ),
 330+ 'deletedOnly', 'mw-show-deleted-only', $this->opts['deletedOnly'] ) .
324331 ( $tagFilter ? Xml::tags( 'p', null, implode( '&nbsp;', $tagFilter ) ) : '' ) .
325332 Xml::openElement( 'p' ) .
326333 '<span style="white-space: nowrap">' .
@@ -367,7 +374,7 @@
368375 $target = $this->opts['target'] == 'newbies' ? 'newbies' : $nt->getText();
369376
370377 $pager = new ContribsPager( $target, $this->opts['namespace'],
371 - $this->opts['year'], $this->opts['month'], $this->opts['tagfilter'] );
 378+ $this->opts['year'], $this->opts['month'], $this->opts['tagfilter'], $this->opts['deletedOnly'] );
372379
373380 $pager->mLimit = min( $this->opts['limit'], $wgFeedLimit );
374381
@@ -431,7 +438,7 @@
432439 var $messages, $target;
433440 var $namespace = '', $mDb;
434441
435 - function __construct( $target, $namespace = false, $year = false, $month = false, $tagFilter = false ) {
 442+ function __construct( $target, $namespace = false, $year = false, $month = false, $tagFilter = false, $deletedOnly = false ) {
436443 parent::__construct();
437444
438445 $msgs = array( 'uctop', 'diff', 'newarticle', 'rollbacklink', 'diff', 'hist', 'rev-delundel', 'pipe-separator' );
@@ -443,6 +450,7 @@
444451 $this->target = $target;
445452 $this->namespace = $namespace;
446453 $this->tagFilter = $tagFilter;
 454+ $this->deletedOnly = $deletedOnly;
447455
448456 $this->getDateCond( $year, $month );
449457
@@ -510,6 +518,9 @@
511519 $condition['rev_user_text'] = $this->target;
512520 $index = 'usertext_timestamp';
513521 }
 522+ if ( $this->deletedOnly ) {
 523+ $condition[] = "rev_deleted != '0'";
 524+ }
514525 return array( $tables, $index, $condition, $join_conds );
515526 }
516527
@@ -673,4 +684,15 @@
674685 return $this->mDb;
675686 }
676687
 688+ /**
 689+ * Overwrite Pager function and return a helpful comment
 690+ */
 691+ function getSqlComment() {
 692+ if ( $this->namespace || $this->deletedOnly ) {
 693+ return 'contributions page filtered for namespace or RevisionDeleted edits'; // potentially slow, see CR r58153
 694+ } else {
 695+ return 'contributions page unfiltered';
 696+ }
 697+ }
 698+
677699 }
Index: trunk/phase3/RELEASE-NOTES
@@ -54,6 +54,7 @@
5555 * (bug 22647) Add category details in search results.
5656 * (bug 23276) Add hook to Special:NewPages to modify query
5757 * Add accesskey 's' and tooltip to 'Save' button at Special:Preferences
 58+* (bug 20186) Allow filtering Special:Contributions for RevisionDeleted edits
5859
5960 === Bug fixes in 1.17 ===
6061 * (bug 17560) Half-broken deletion moved image files to deletion archive

Follow-up revisions

RevisionCommit summaryAuthorDate
r65637fixing r65546: move variable decleration upchurchofemacs21:43, 28 April 2010
r65651follow-up on r65546#c6661: minor code style issue. (suggested by Nikerabbit)churchofemacs10:28, 29 April 2010

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r58153Partially fixing bug 20186: Allow filtering history for revision deletion. Ch...churchofemacs18:45, 26 October 2009

Comments

#Comment by Raymond (talk | contribs)   21:13, 28 April 2010

Seen on translatewiki today:

PHP Notice: Undefined index: deletedOnly in /www/w/includes/specials/SpecialContributions.php  on line 329
#Comment by Church of emacs (talk | contribs)   21:47, 28 April 2010

The error seems to have occurred on Special:Contributions (without any parameters). Fixed in r65637.

Note that if you call getForm() before execute(), you'll still get an error. However, I don't see that ever happening and I don't want to include superfluous code to prevent such an obscure scenario.

#Comment by Nikerabbit (talk | contribs)   07:46, 29 April 2010

$wgRequest->getCheck perhaps?

#Comment by Church of emacs (talk | contribs)   10:29, 29 April 2010

Done in r65651.

Status & tagging log