From 287cca8069f24b94991a48b15ab03d3dcb52fb43 Mon Sep 17 00:00:00 2001 From: Daniel Cannon Date: Tue, 4 Dec 2007 22:08:50 +0000 Subject: [PATCH] * Only show most recent 5000 revisions on Special:Undelete by default. Accept limit and offset parameters. Undelete with no revisions selected still undeletes all revisions, regardless of how many are displayed. --- RELEASE-NOTES | 3 +++ includes/SpecialUndelete.php | 42 +++++++++++++++++++++++-------- languages/messages/MessagesEn.php | 3 +++ 3 files changed, 38 insertions(+), 10 deletions(-) diff --git a/RELEASE-NOTES b/RELEASE-NOTES index 57fdaa2737..0dcc80f593 100644 --- a/RELEASE-NOTES +++ b/RELEASE-NOTES @@ -87,6 +87,9 @@ it from source control: http://www.mediawiki.org/wiki/Download_from_SVN does not exists * (bug 8396) Ignore out-of-date serialised message caches * (bug 12195) Undeleting pages now requires 'undelete' permission +* Only show most recent 5000 revisions on Special:Undelete by default. Accept + limit and offset parameters. Undelete with no revisions selected still + undeletes all revisions, regardless of how many are displayed. === Bug fixes in 1.12 === diff --git a/includes/SpecialUndelete.php b/includes/SpecialUndelete.php index 06d66a2b85..a49bd7176d 100644 --- a/includes/SpecialUndelete.php +++ b/includes/SpecialUndelete.php @@ -97,14 +97,19 @@ class PageArchive { * * @return ResultWrapper */ - function listRevisions() { + function listRevisions( $startTime, $limit ) { + $whereClause = array( 'ar_namespace' => $this->title->getNamespace(), + 'ar_title' => $this->title->getDBkey() ); + if ( $startTime ) + $whereClause[] = "ar_timestamp < $startTime"; + $dbr = wfGetDB( DB_SLAVE ); $res = $dbr->select( 'archive', array( 'ar_minor_edit', 'ar_timestamp', 'ar_user', 'ar_user_text', 'ar_comment', 'ar_len' ), - array( 'ar_namespace' => $this->title->getNamespace(), - 'ar_title' => $this->title->getDBkey() ), + $whereClause, 'PageArchive::listRevisions', - array( 'ORDER BY' => 'ar_timestamp DESC' ) ); + array( 'ORDER BY' => 'ar_timestamp DESC', + 'LIMIT' => intval($limit) ) ); $ret = $dbr->resultObject( $res ); return $ret; } @@ -822,7 +827,7 @@ class UndeleteForm { } /* private */ function showHistory() { - global $wgLang, $wgContLang, $wgUser, $wgOut; + global $wgLang, $wgContLang, $wgUser, $wgOut, $wgRequest; $sk = $wgUser->getSkin(); if ( $this->mAllowed ) { @@ -846,12 +851,28 @@ class UndeleteForm { } # List all stored revisions - $revisions = $archive->listRevisions(); + $tmpLimit = $wgRequest->getIntOrNull ( 'limit' ); + $tmpLimit = (is_null($tmpLimit))? 5001 : $tmpLimit + 1; + $revisions = $archive->listRevisions( $wgRequest->getVal ( 'offset' ), + $tmpLimit ); $files = $archive->listFiles(); $haveRevisions = $revisions && $revisions->numRows() > 0; $haveFiles = $files && $files->numRows() > 0; + $hasMore = false; + if ( $revisions && $revisions->numRows() >= $tmpLimit ) { + $revisions->seek ( $revisions->numRows() - 2 ); + $tmp = $revisions->fetchObject(); + $revisions->rewind ( ); + + $titleObj = SpecialPage::getTitleFor ( 'Undelete' ); + $tmplink = $sk->makeKnownLinkObj ( $titleObj, wfMsg( 'undelete-next-revs', 5000 ), + "target={$this->mTarget}&limit=5000&offset={$tmp->ar_timestamp}" ); + + $wgOut->addHTML ( wfMsg ( 'undelete-more-revs', $tmpLimit - 1, $tmplink ) ); + $hasMore = true; + } # Batch existence check on user and talk pages if( $haveRevisions ) { $batch = new LinkBatch(); @@ -935,16 +956,17 @@ class UndeleteForm { $target = urlencode( $this->mTarget ); $remaining = $revisions->numRows(); $earliestLiveTime = $this->getEarliestTime( $this->mTargetObj ); - - while( $row = $revisions->fetchObject() ) { - $remaining--; + + if ( $hasMore ) $remaining --; + + while( ( $row = $revisions->fetchObject() ) && $remaining-- ) { $ts = wfTimestamp( TS_MW, $row->ar_timestamp ); if ( $this->mAllowed ) { $checkBox = Xml::check( "ts$ts" ); $pageLink = $sk->makeKnownLinkObj( $titleObj, $wgLang->timeanddate( $ts, true ), "target=$target×tamp=$ts" ); - if( ($remaining > 0) || + if( ($remaining > 0 || $hasMore ) || ($earliestLiveTime && $ts > $earliestLiveTime ) ) { $diffLink = '(' . $sk->makeKnownLinkObj( $titleObj, diff --git a/languages/messages/MessagesEn.php b/languages/messages/MessagesEn.php index 6fd29e4b3f..af01d52981 100644 --- a/languages/messages/MessagesEn.php +++ b/languages/messages/MessagesEn.php @@ -2006,6 +2006,9 @@ Consult the [[Special:Log/delete|deletion log]] for a record of recent deletions 'It may have already been undeleted.', 'undelete-error-short' => 'Error undeleting file: $1', 'undelete-error-long' => "Errors were encountered while undeleting the file:\n\n$1", +'undelete-more-revs' => 'WARNING! This page has more deleted revisions than are displayed here.
+$1 revisions are displayed below. You may select revisions from this list or select none to restore all revisions (including those not displayed). ($2)', +'undelete-next-revs' => 'View next $1 revisions', # Namespace form on various pages 'namespace' => 'Namespace:', -- 2.20.1