From f4c55344eff5174d34c14fd88683a5a00d8a39d5 Mon Sep 17 00:00:00 2001 From: Tobias Date: Mon, 26 Oct 2009 18:45:27 +0000 Subject: [PATCH] Partially fixing bug 20186: Allow filtering history for revision deletion. Checking for isBigDeletion to exclude large page histories. Also available only to users with deleterevision permission (paranoia) --- RELEASE-NOTES | 1 + includes/HistoryPage.php | 26 +++++++++++++++++++++----- languages/messages/MessagesEn.php | 1 + maintenance/language/messages.inc | 1 + 4 files changed, 24 insertions(+), 5 deletions(-) diff --git a/RELEASE-NOTES b/RELEASE-NOTES index 72eec62a16..2abe831126 100644 --- a/RELEASE-NOTES +++ b/RELEASE-NOTES @@ -262,6 +262,7 @@ it from source control: http://www.mediawiki.org/wiki/Download_from_SVN * (bug 3480) The warning saying that the page has a history when deleting it now contains the number of revisions in the history * $wgStylePath and $wgLogo are now set in the default LocalSettings.php file. +* (bug 20186) Allow filtering history for revision deletion. === Bug fixes in 1.16 === diff --git a/includes/HistoryPage.php b/includes/HistoryPage.php index 2c43285b62..9a620e66b4 100644 --- a/includes/HistoryPage.php +++ b/includes/HistoryPage.php @@ -129,6 +129,20 @@ class HistoryPage { $month = $wgRequest->getInt( 'month' ); $tagFilter = $wgRequest->getVal( 'tagfilter' ); $tagSelector = ChangeTags::buildTagFilterSelector( $tagFilter ); + /** + * Option to show only revisions that have been (partially) hidden via RevisionDelete + * Note that this can run a *long* time if there are many revisions to look at. + * We use "isBigDeletion" to determine if the history is too big to go through. + * Additionally, only users with 'deleterevision' right can filter for deleted edits. + */ + if ( $this->title->userCan( 'deleterevision' ) && ( !$this->article->isBigDeletion() || $this->title->userCan( 'bigdelete' ) ) ) { + $conds = ( $wgRequest->getBool( 'deleted' ) ) ? array("rev_deleted != '0'") : array(); + $checkDeleted = Xml::checkLabel( wfMsg( 'history-show-deleted' ), 'deleted', '', $wgRequest->getBool( 'deleted' ) ) . "\n"; + } + else { # Don't filter and don't add the checkbox for filtering + $conds = array(); + $checkDeleted = ''; + } $action = htmlspecialchars( $wgScript ); $wgOut->addHTML( @@ -140,8 +154,9 @@ class HistoryPage { ) . Xml::hidden( 'title', $this->title->getPrefixedDBKey() ) . "\n" . Xml::hidden( 'action', 'history' ) . "\n" . - xml::dateMenu( $year, $month ) . ' ' . + Xml::dateMenu( $year, $month ) . ' ' . ( $tagSelector ? ( implode( ' ', $tagSelector ) . ' ' ) : '' ) . + $checkDeleted . Xml::submitButton( wfMsg( 'allpagessubmit' ) ) . "\n" . '' ); @@ -151,7 +166,7 @@ class HistoryPage { /** * Do the list */ - $pager = new HistoryPager( $this, $year, $month, $tagFilter ); + $pager = new HistoryPager( $this, $year, $month, $tagFilter, $conds ); $wgOut->addHTML( $pager->getNavigationBar() . $pager->getBody() . @@ -284,15 +299,16 @@ class HistoryPage { * @ingroup Pager */ class HistoryPager extends ReverseChronologicalPager { - public $lastRow = false, $counter, $historyPage, $title, $buttons; + public $lastRow = false, $counter, $historyPage, $title, $buttons, $conds; protected $oldIdChecked; - function __construct( $historyPage, $year='', $month='', $tagFilter = '' ) { + function __construct( $historyPage, $year='', $month='', $tagFilter = '', $conds = array() ) { parent::__construct(); $this->historyPage = $historyPage; $this->title = $this->historyPage->title; $this->tagFilter = $tagFilter; $this->getDateCond( $year, $month ); + $this->conds = $conds; } // For hook compatibility... @@ -304,7 +320,7 @@ class HistoryPager extends ReverseChronologicalPager { $queryInfo = array( 'tables' => array('revision'), 'fields' => array_merge( Revision::selectFields(), array('ts_tags') ), - 'conds' => array('rev_page' => $this->historyPage->title->getArticleID() ), + 'conds' => array_merge( array('rev_page' => $this->historyPage->title->getArticleID() ), $this->conds ), 'options' => array( 'USE INDEX' => array('revision' => 'page_timestamp') ), 'join_conds' => array( 'tag_summary' => array( 'LEFT JOIN', 'ts_rev_id=rev_id' ) ), ); diff --git a/languages/messages/MessagesEn.php b/languages/messages/MessagesEn.php index 485ac70f12..f4383a498e 100644 --- a/languages/messages/MessagesEn.php +++ b/languages/messages/MessagesEn.php @@ -1407,6 +1407,7 @@ The reason given by $3 is ''$2''", Legend: '''({{int:cur}})''' = difference with current revision, '''({{int:last}})''' = difference with preceding revision, '''{{int:minoreditletter}}''' = minor edit.", 'history-fieldset-title' => 'Browse history', +'history-show-deleted' => 'Deleted only', 'history_copyright' => '-', # do not translate or duplicate this message to other languages 'histfirst' => 'Earliest', 'histlast' => 'Latest', diff --git a/maintenance/language/messages.inc b/maintenance/language/messages.inc index 990f364368..f6d7536bca 100644 --- a/maintenance/language/messages.inc +++ b/maintenance/language/messages.inc @@ -641,6 +641,7 @@ $wgMessageStructure = array( 'page_last', 'histlegend', 'history-fieldset-title', + 'history-show-deleted', 'history_copyright', 'histfirst', 'histlast', -- 2.20.1