From 12a1445ac7a36c6e7fcff8dc2cf936a5e35646bc Mon Sep 17 00:00:00 2001 From: Tobias Date: Mon, 26 Apr 2010 16:35:02 +0000 Subject: [PATCH] fixing bug 20186: allow filtering SpecialContributions for RevisionDeleted edits. See also bug 20186 comment 22 --- RELEASE-NOTES | 1 + includes/specials/SpecialContributions.php | 32 ++++++++++++++++++---- 2 files changed, 28 insertions(+), 5 deletions(-) diff --git a/RELEASE-NOTES b/RELEASE-NOTES index cca242a375..99d8bc0a9c 100644 --- a/RELEASE-NOTES +++ b/RELEASE-NOTES @@ -54,6 +54,7 @@ it from source control: http://www.mediawiki.org/wiki/Download_from_SVN * (bug 22647) Add category details in search results. * (bug 23276) Add hook to Special:NewPages to modify query * Add accesskey 's' and tooltip to 'Save' button at Special:Preferences +* (bug 20186) Allow filtering Special:Contributions for RevisionDeleted edits === Bug fixes in 1.17 === * (bug 17560) Half-broken deletion moved image files to deletion archive diff --git a/includes/specials/SpecialContributions.php b/includes/specials/SpecialContributions.php index d8f9b8003d..9f5219f915 100644 --- a/includes/specials/SpecialContributions.php +++ b/includes/specials/SpecialContributions.php @@ -64,6 +64,8 @@ class SpecialContributions extends SpecialPage { $this->opts['namespace'] = ''; } + $this->opts['deletedOnly'] = ( $wgRequest->getVal( 'deletedOnly' ) == '1' ); + $this->opts['tagfilter'] = (string) $wgRequest->getVal( 'tagfilter' ); // Allows reverts to have the bot flag in recent changes. It is just here to @@ -93,7 +95,8 @@ class SpecialContributions extends SpecialPage { $wgOut->addHTML( $this->getForm() ); - $pager = new ContribsPager( $target, $this->opts['namespace'], $this->opts['year'], $this->opts['month'] ); + $pager = new ContribsPager( $target, $this->opts['namespace'], $this->opts['year'], + $this->opts['month'], false, $this->opts['deletedOnly'] ); if( !$pager->getNumRows() ) { $wgOut->addWikiMsg( 'nocontribs', $target ); } else { @@ -296,9 +299,11 @@ class SpecialContributions extends SpecialPage { } $f = Xml::openElement( 'form', array( 'method' => 'get', 'action' => $wgScript ) ); - # Add hidden params for tracking + + # Add hidden params for tracking except for parameters in $skipParameters + $skipParameters = array( 'namespace', 'deletedOnly', 'target', 'contribs', 'year', 'month' ); foreach ( $this->opts as $name => $value ) { - if( in_array( $name, array( 'namespace', 'target', 'contribs', 'year', 'month' ) ) ) { + if( in_array( $name, $skipParameters ) ) { continue; } $f .= "\t" . Xml::hidden( $name, $value ) . "\n"; @@ -320,6 +325,8 @@ class SpecialContributions extends SpecialPage { Xml::label( wfMsg( 'namespace' ), 'namespace' ) . ' ' . Xml::namespaceSelector( $this->opts['namespace'], '' ) . '' . + Xml::checkLabel( wfMsg( 'history-show-deleted' ), + 'deletedOnly', 'mw-show-deleted-only', $this->opts['deletedOnly'] ) . ( $tagFilter ? Xml::tags( 'p', null, implode( ' ', $tagFilter ) ) : '' ) . Xml::openElement( 'p' ) . '' . @@ -367,7 +374,7 @@ class SpecialContributions extends SpecialPage { $target = $this->opts['target'] == 'newbies' ? 'newbies' : $nt->getText(); $pager = new ContribsPager( $target, $this->opts['namespace'], - $this->opts['year'], $this->opts['month'], $this->opts['tagfilter'] ); + $this->opts['year'], $this->opts['month'], $this->opts['tagfilter'], $this->opts['deletedOnly'] ); $pager->mLimit = min( $this->opts['limit'], $wgFeedLimit ); @@ -431,7 +438,7 @@ class ContribsPager extends ReverseChronologicalPager { var $messages, $target; var $namespace = '', $mDb; - function __construct( $target, $namespace = false, $year = false, $month = false, $tagFilter = false ) { + function __construct( $target, $namespace = false, $year = false, $month = false, $tagFilter = false, $deletedOnly = false ) { parent::__construct(); $msgs = array( 'uctop', 'diff', 'newarticle', 'rollbacklink', 'diff', 'hist', 'rev-delundel', 'pipe-separator' ); @@ -443,6 +450,7 @@ class ContribsPager extends ReverseChronologicalPager { $this->target = $target; $this->namespace = $namespace; $this->tagFilter = $tagFilter; + $this->deletedOnly = $deletedOnly; $this->getDateCond( $year, $month ); @@ -510,6 +518,9 @@ class ContribsPager extends ReverseChronologicalPager { $condition['rev_user_text'] = $this->target; $index = 'usertext_timestamp'; } + if ( $this->deletedOnly ) { + $condition[] = "rev_deleted != '0'"; + } return array( $tables, $index, $condition, $join_conds ); } @@ -673,4 +684,15 @@ class ContribsPager extends ReverseChronologicalPager { return $this->mDb; } + /** + * Overwrite Pager function and return a helpful comment + */ + function getSqlComment() { + if ( $this->namespace || $this->deletedOnly ) { + return 'contributions page filtered for namespace or RevisionDeleted edits'; // potentially slow, see CR r58153 + } else { + return 'contributions page unfiltered'; + } + } + } -- 2.20.1