r77007 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r77006‎ | r77007 | r77008 >
Date:06:16, 19 November 2010
Author:aaron
Status:deferred
Tags:
Comment:
Follow ups for r76962 and r75408:
* Use rev IDs for both summary cases to avoid timestamp offset problems
* Deal with 4+ authors case differently in default summary
* Use review_bad_oldid error detection on pre-confirm reject rather than fatal
* Reverted r76978, I shouldn't have suggested it (keys not reset)
* Added sanity check to avoid insane queries (250 limit)
* Fix for case when $this->comment is '0'
* Shortened revreview-reject msg keys a bit
* Added changetime field to RevisionReviewForm (for use later)
Modified paths:
  • /trunk/extensions/FlaggedRevs/forms/RevisionReviewForm.php (modified) (history)
  • /trunk/extensions/FlaggedRevs/language/FlaggedRevs.i18n.php (modified) (history)
  • /trunk/extensions/FlaggedRevs/specialpages/RevisionReview_body.php (modified) (history)

Diff [purge]

Index: trunk/extensions/FlaggedRevs/language/FlaggedRevs.i18n.php
@@ -256,8 +256,12 @@
257257 'revreview-reject-summary' => 'Edit summary:',
258258 'revreview-reject-confirm' => 'Reject these changes',
259259 'revreview-reject-cancel' => 'Cancel',
260 - 'revreview-reject-default-summary-cur' => 'Rejected {{PLURAL:$1|one change|$1 changes}} by $2 to version as of $3',
261 - 'revreview-reject-default-summary-old' => 'Rejected {{PLURAL:$1|one change|$1 changes}} by $2',
 260+ 'revreview-reject-summary-cur' => 'Rejected the last {{PLURAL:$1|one change|$1 changes}} (by $2) and restored revision $3',
 261+ 'revreview-reject-summary-old' => 'Rejected the first {{PLURAL:$1|one change|$1 changes}} (by $2) following revision $3',
 262+ 'revreview-reject-summary-cur-short' => 'Rejected the last {{PLURAL:$1|one change|$1 changes}} and restored revision $2',
 263+ 'revreview-reject-summary-old-short' => 'Rejected the first {{PLURAL:$1|one change|$1 changes}} following revision $2',
 264+ 'revreview-reject-usercount' => '{{PLURAL:$1|one user|$1 users}}',
 265+ 'revreview-reject-toomanyedits' => 'Cannot reject this many edits at once.',
262266
263267 'revreview-reviewlink' => 'pending edits',
264268 'revreview-reviewlink-title' => 'View diff of all pending changes',
@@ -577,12 +581,12 @@
578582 'revreview-lev-quality' => '{{Flagged Revs}}',
579583 'revreview-lev-pristine' => '{{Flagged Revs}}',
580584 'revreview-reject-cancel' => '{{Identical|Cancel}}',
581 - 'revreview-reject-default-summary-cur' => '{{Flagged Revs-small}}
 585+ 'revreview-reject-summary-cur' => '{{Flagged Revs-small}}
582586 Default summary shown when rejecting pending changes, and they are the latest revisions to a page
583587 * $1 is the number of rejected revisions
584588 * $2 is the list of (one or more) users who are being rejected
585589 * $3 is the timestamp of the revision being reverted to',
586 - 'revreview-reject-default-summary-old' => '{{Flagged Revs-small}}
 590+ 'revreview-reject-summary-old' => '{{Flagged Revs-small}}
587591 Default summary shown when rejecting pending changes.
588592 * $1 is the number of rejected revisions
589593 * $2 is the list of (one or more) users who are being rejected',
Index: trunk/extensions/FlaggedRevs/forms/RevisionReviewForm.php
@@ -28,6 +28,7 @@
2929 protected $notes = '';
3030 protected $comment = '';
3131 protected $dims = array();
 32+ protected $lastChangeTime = '';
3233
3334 protected $oflags = array();
3435 protected $inputLock = 0; # Disallow bad submissions
@@ -67,6 +68,10 @@
6869 $this->trySet( $this->rejectConfirm, $value );
6970 }
7071
 72+ public function setLastChangeTime( $value ) {
 73+ $this->trySet( $this->lastChangeTime, $value );
 74+ }
 75+
7176 public function getRefId() {
7277 return $this->refid;
7378 }
@@ -307,17 +312,17 @@
308313 } elseif ( $this->getAction() === 'reject' ) {
309314 $newRev = Revision::newFromTitle( $this->page, $this->oldid );
310315 $oldRev = Revision::newFromTitle( $this->page, $this->refid );
311 -
312 - if( !$this->rejectConfirm ) {
313 - $this->rejectConfirmationForm( $oldRev, $newRev );
314 - return false;
315 - }
316316 # Do not mess with archived/deleted revisions
317317 if ( is_null( $oldRev ) || $oldRev->mDeleted ) {
318318 return 'review_bad_oldid';
319319 } elseif ( is_null( $newRev ) || $newRev->mDeleted ) {
320320 return 'review_bad_oldid';
321321 }
 322+ # Go to confirmation screen first
 323+ if ( !$this->rejectConfirm ) {
 324+ $this->rejectConfirmationForm( $oldRev, $newRev );
 325+ return false; // xxx
 326+ }
322327 $article = new Article( $this->page );
323328 $new_text = $article->getUndoText( $newRev, $oldRev );
324329 if ( $new_text === false ) {
@@ -634,6 +639,7 @@
635640 $oldFlags = $frev
636641 ? $frev->getTags() // existing tags
637642 : FlaggedRevs::quickTags( FR_CHECKED ); // basic tags
 643+ $reviewTime = $frev ? $frev->getTimestamp() : ''; // last review of rev
638644
639645 # If we are reviewing updates to a page, start off with the stable revision's
640646 # flags. Otherwise, we just fill them in with the selected revision's flags.
@@ -769,6 +775,7 @@
770776 $form .= Html::hidden( 'oldid', $id ) . "\n";
771777 $form .= Html::hidden( 'action', 'submit' ) . "\n";
772778 $form .= Html::hidden( 'wpEditToken', $user->editToken() ) . "\n";
 779+ $form .= Html::hidden( 'changetime', $reviewTime );
773780 # Add review parameters
774781 $form .= Html::hidden( 'templateParams', $templateParams ) . "\n";
775782 $form .= Html::hidden( 'imageParams', $imageParams ) . "\n";
@@ -998,26 +1005,27 @@
9991006 $wgOut->addHtml( '<div class="plainlinks">' );
10001007
10011008 $dbr = wfGetDB( DB_SLAVE );
1002 - $oldid = $dbr->addQuotes( $oldRev->getId() );
1003 - $newid = $dbr->addQuotes( $newRev->getId() );
10041009 $res = $dbr->select( 'revision',
10051010 array( 'rev_id', 'rev_user_text' ),
10061011 array(
1007 - 'rev_id > ' . $oldid,
1008 - 'rev_id <= ' . $newid,
1009 - 'rev_page' => $oldRev->getPage()
 1012+ 'rev_page' => $oldRev->getPage(),
 1013+ 'rev_id > ' . $dbr->addQuotes( $oldRev->getId() ),
 1014+ 'rev_id <= ' . $dbr->addQuotes( $newRev->getId() )
10101015 ),
1011 - __METHOD__
 1016+ __METHOD__,
 1017+ array( 'LIMIT' => 251 ) // sanity check
10121018 );
1013 - if ( !$dbr->numRows( $res ) ) { // sanity check
1014 - $wgOut->redirect( $this->getPage()->getFullUrl() );
 1019+ if ( !$dbr->numRows( $res ) ) {
 1020+ $wgOut->redirect( $this->getPage()->getFullUrl() ); // sanity check
10151021 return;
 1022+ } elseif ( $dbr->numRows( $res ) > 250 ) {
 1023+ $wgOut->showErrorPage( 'internalerror', 'revreview-reject-toomanyedits' );
 1024+ return;
10161025 }
10171026
10181027 $rejectIds = array();
1019 - foreach( $res as $r ) {
1020 - $rejectIds[$r->rev_id] =
1021 - "[[User:{$r->rev_user_text}|{$r->rev_user_text}]]";
 1028+ foreach ( $res as $r ) {
 1029+ $rejectIds[$r->rev_id] = "[[User:{$r->rev_user_text}|{$r->rev_user_text}]]";
10221030 }
10231031
10241032 // List of revisions being undone...
@@ -1035,27 +1043,39 @@
10361044 }
10371045 }
10381046 $wgOut->addHtml( '</ul>' );
1039 - // Revision this will revert to (when reverting the top X revs)...
10401047 if ( $newRev->isCurrent() ) {
 1048+ // Revision this will revert to (when reverting the top X revs)...
10411049 $wgOut->addWikiMsg( 'revreview-reject-text-revto',
10421050 $oldRev->getTitle()->getPrefixedDBKey(), $oldRev->getId(),
1043 - $wgLang->timeanddate( $oldRev->getTimestamp(), true ) );
1044 - $defaultSummary = wfMsgExt( 'revreview-reject-default-summary-cur',
1045 - array( 'parsemag' ),
1046 - $wgLang->formatNum( count( $rejectIds ) ),
1047 - $wgLang->listToText( array_unique( array_values( $rejectIds ) ) ),
10481051 $wgLang->timeanddate( $oldRev->getTimestamp(), true )
10491052 );
 1053+ }
 1054+
 1055+ // Determine the default edit summary...
 1056+ // NOTE: *-cur msg wording not safe for (unlikely) edit auto-merge
 1057+ $rejectAuthors = array_values( array_unique( $rejectIds ) );
 1058+ if ( count( $rejectAuthors ) > 3 ) {
 1059+ $msg = $newRev->isCurrent()
 1060+ ? 'revreview-reject-summary-cur-short'
 1061+ : 'revreview-reject-summary-old-short';
 1062+ $defaultSummary = wfMsgExt( $msg, 'parsemag',
 1063+ $wgLang->formatNum( count( $rejectIds ) ), $oldRev->getId() );
10501064 } else {
1051 - $defaultSummary = wfMsgExt( 'revreview-reject-default-summary-old',
1052 - array( 'parsemag' ),
1053 - $wgLang->formatNum( count( $rejectIds ) ),
1054 - $wgLang->listToText( array_unique( array_values( $rejectIds ) ) )
 1065+ $msg = $newRev->isCurrent()
 1066+ ? 'revreview-reject-summary-cur'
 1067+ : 'revreview-reject-summary-old';
 1068+ $defaultSummary = wfMsgExt( $msg, 'parsemag',
 1069+ $wgLang->formatNum( count( $rejectIds ) ),
 1070+ $wgLang->listToText( $rejectAuthors ),
 1071+ $oldRev->getId()
10551072 );
10561073 }
1057 -
1058 - if( $this->comment ) {
1059 - $defaultSummary = "{$defaultSummary}: {$this->comment}";
 1074+ // Append any review comment...
 1075+ if ( $this->comment != '' ) {
 1076+ if ( $defaultSummary != '' ) {
 1077+ $defaultSummary .= wfMsgForContent( 'colon-separator' );
 1078+ }
 1079+ $defaultSummary .= $this->comment;
10601080 }
10611081
10621082 $wgOut->addHtml( '</div>' );
@@ -1070,12 +1090,14 @@
10711091 $form .= Html::hidden( 'refid', $this->refid );
10721092 $form .= Html::hidden( 'target', $oldRev->getTitle()->getPrefixedDBKey() );
10731093 $form .= Html::hidden( 'wpEditToken', $this->user->editToken() );
 1094+ $form .= Html::hidden( 'changetime', $newRev->getTimestamp() );
10741095 $form .= Xml::inputLabel( wfMsg( 'revreview-reject-summary' ), 'wpReason',
10751096 'wpReason', 120, $defaultSummary ) . "<br />";
10761097 $form .= Html::input( 'wpSubmit', wfMsg( 'revreview-reject-confirm' ), 'submit' );
10771098 $form .= Html::input( 'wpCancel', wfMsg( 'revreview-reject-cancel' ),
10781099 'button', array( 'onClick' => 'history.back();' ) );
10791100 $form .= Xml::closeElement( 'form' );
 1101+
10801102 $wgOut->addHtml( $form );
10811103 }
10821104
Index: trunk/extensions/FlaggedRevs/specialpages/RevisionReview_body.php
@@ -56,6 +56,8 @@
5757 $form->setFileVersion( $wgRequest->getVal( 'fileVersion' ) );
5858 # Special token to discourage fiddling...
5959 $form->setValidatedParams( $wgRequest->getVal( 'validatedParams' ) );
 60+ # Conflict handling
 61+ $form->setLastChangeTime( $wgRequest->getVal( 'changetime' ) );
6062 # Tag values
6163 foreach ( FlaggedRevs::getTags() as $tag ) {
6264 # This can be NULL if we uncheck a checkbox

Follow-up revisions

RevisionCommit summaryAuthorDate
r77008Follow-up r77007: update qqqaaron06:28, 19 November 2010

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r75408(bug 25294) "Reject" button confirmation screen in Pending Changedemon02:36, 26 October 2010
r76962Message cleanup for r75408:...demon21:25, 18 November 2010
r76978Nitpick: switch array unique/values calls for claritydemon22:17, 18 November 2010

Status & tagging log