r28158 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r28157‎ | r28158 | r28159 >
Date:22:08, 4 December 2007
Author:amidaniel
Status:old
Tags:
Comment:
* 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.
Modified paths:
  • /trunk/phase3/RELEASE-NOTES (modified) (history)
  • /trunk/phase3/includes/SpecialUndelete.php (modified) (history)
  • /trunk/phase3/languages/messages/MessagesEn.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/SpecialUndelete.php
@@ -97,14 +97,19 @@
9898 *
9999 * @return ResultWrapper
100100 */
101 - function listRevisions() {
 101+ function listRevisions( $startTime, $limit ) {
 102+ $whereClause = array( 'ar_namespace' => $this->title->getNamespace(),
 103+ 'ar_title' => $this->title->getDBkey() );
 104+ if ( $startTime )
 105+ $whereClause[] = "ar_timestamp < $startTime";
 106+
102107 $dbr = wfGetDB( DB_SLAVE );
103108 $res = $dbr->select( 'archive',
104109 array( 'ar_minor_edit', 'ar_timestamp', 'ar_user', 'ar_user_text', 'ar_comment', 'ar_len' ),
105 - array( 'ar_namespace' => $this->title->getNamespace(),
106 - 'ar_title' => $this->title->getDBkey() ),
 110+ $whereClause,
107111 'PageArchive::listRevisions',
108 - array( 'ORDER BY' => 'ar_timestamp DESC' ) );
 112+ array( 'ORDER BY' => 'ar_timestamp DESC',
 113+ 'LIMIT' => intval($limit) ) );
109114 $ret = $dbr->resultObject( $res );
110115 return $ret;
111116 }
@@ -822,7 +827,7 @@
823828 }
824829
825830 /* private */ function showHistory() {
826 - global $wgLang, $wgContLang, $wgUser, $wgOut;
 831+ global $wgLang, $wgContLang, $wgUser, $wgOut, $wgRequest;
827832
828833 $sk = $wgUser->getSkin();
829834 if ( $this->mAllowed ) {
@@ -846,12 +851,28 @@
847852 }
848853
849854 # List all stored revisions
850 - $revisions = $archive->listRevisions();
 855+ $tmpLimit = $wgRequest->getIntOrNull ( 'limit' );
 856+ $tmpLimit = (is_null($tmpLimit))? 5001 : $tmpLimit + 1;
 857+ $revisions = $archive->listRevisions( $wgRequest->getVal ( 'offset' ),
 858+ $tmpLimit );
851859 $files = $archive->listFiles();
852860
853861 $haveRevisions = $revisions && $revisions->numRows() > 0;
854862 $haveFiles = $files && $files->numRows() > 0;
855863
 864+ $hasMore = false;
 865+ if ( $revisions && $revisions->numRows() >= $tmpLimit ) {
 866+ $revisions->seek ( $revisions->numRows() - 2 );
 867+ $tmp = $revisions->fetchObject();
 868+ $revisions->rewind ( );
 869+
 870+ $titleObj = SpecialPage::getTitleFor ( 'Undelete' );
 871+ $tmplink = $sk->makeKnownLinkObj ( $titleObj, wfMsg( 'undelete-next-revs', 5000 ),
 872+ "target={$this->mTarget}&limit=5000&offset={$tmp->ar_timestamp}" );
 873+
 874+ $wgOut->addHTML ( wfMsg ( 'undelete-more-revs', $tmpLimit - 1, $tmplink ) );
 875+ $hasMore = true;
 876+ }
856877 # Batch existence check on user and talk pages
857878 if( $haveRevisions ) {
858879 $batch = new LinkBatch();
@@ -935,16 +956,17 @@
936957 $target = urlencode( $this->mTarget );
937958 $remaining = $revisions->numRows();
938959 $earliestLiveTime = $this->getEarliestTime( $this->mTargetObj );
939 -
940 - while( $row = $revisions->fetchObject() ) {
941 - $remaining--;
 960+
 961+ if ( $hasMore ) $remaining --;
 962+
 963+ while( ( $row = $revisions->fetchObject() ) && $remaining-- ) {
942964 $ts = wfTimestamp( TS_MW, $row->ar_timestamp );
943965 if ( $this->mAllowed ) {
944966 $checkBox = Xml::check( "ts$ts" );
945967 $pageLink = $sk->makeKnownLinkObj( $titleObj,
946968 $wgLang->timeanddate( $ts, true ),
947969 "target=$target&timestamp=$ts" );
948 - if( ($remaining > 0) ||
 970+ if( ($remaining > 0 || $hasMore ) ||
949971 ($earliestLiveTime && $ts > $earliestLiveTime ) ) {
950972 $diffLink = '(' .
951973 $sk->makeKnownLinkObj( $titleObj,
Index: trunk/phase3/languages/messages/MessagesEn.php
@@ -2006,6 +2006,9 @@
20072007 'It may have already been undeleted.',
20082008 'undelete-error-short' => 'Error undeleting file: $1',
20092009 'undelete-error-long' => "Errors were encountered while undeleting the file:\n\n$1",
 2010+'undelete-more-revs' => '<b><font style="color: red">WARNING!</font> This page has more deleted revisions than are displayed here.</b><br />
 2011+$1 revisions are displayed below. You may select revisions from this list or select none to restore all revisions (including those not displayed). ($2)',
 2012+'undelete-next-revs' => 'View next $1 revisions',
20102013
20112014 # Namespace form on various pages
20122015 'namespace' => 'Namespace:',
Index: trunk/phase3/RELEASE-NOTES
@@ -87,6 +87,9 @@
8888 does not exists
8989 * (bug 8396) Ignore out-of-date serialised message caches
9090 * (bug 12195) Undeleting pages now requires 'undelete' permission
 91+* Only show most recent 5000 revisions on Special:Undelete by default. Accept
 92+ limit and offset parameters. Undelete with no revisions selected still
 93+ undeletes all revisions, regardless of how many are displayed.
9194
9295 === Bug fixes in 1.12 ===
9396

Follow-up revisions

RevisionCommit summaryAuthorDate
r28179Revert r28158, 28159, 28160, 28164:...brion15:19, 5 December 2007

Status & tagging log