r75408 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r75407‎ | r75408 | r75409 >
Date:02:36, 26 October 2010
Author:demon
Status:resolved (Comments)
Tags:
Comment:
(bug 25294) "Reject" button confirmation screen in Pending Change
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
@@ -249,6 +249,13 @@
250250 'revreview-restriction-any' => 'any',
251251 'revreview-restriction-none' => 'none',
252252
 253+ 'revreview-reject-header' => 'Reject changes for $1',
 254+ 'revreview-reject-text' => 'By completing this action, you will be \'\'\'rejecting\'\'\' the following changes. This will revert the article back to this [$1 older revision]',
 255+ 'revreview-reject-summary' => 'Edit summary:',
 256+ 'revreview-reject-confirm' => 'Reject these changes',
 257+ 'revreview-reject-cancel' => 'Cancel',
 258+ 'revreview-reject-default-summary' => 'Rejecting changes by [[User:$1|$1]] to version $2 by [[User:$3|$3]]',
 259+
253260 'revreview-reviewlink' => 'pending edits',
254261 'revreview-reviewlink-title' => 'View diff of all pending changes',
255262 'revreview-unreviewedpage' => 'unchecked page',
Index: trunk/extensions/FlaggedRevs/forms/RevisionReviewForm.php
@@ -18,6 +18,7 @@
1919 protected $approve = false;
2020 protected $unapprove = false;
2121 protected $reject = false;
 22+ protected $rejectConfirm = false;
2223 protected $oldid = 0;
2324 protected $refid = 0;
2425 protected $templateParams = '';
@@ -63,6 +64,10 @@
6465 $this->trySet( $this->reject, $value );
6566 }
6667
 68+ public function setRejectConfirm( $value ) {
 69+ $this->trySet( $this->rejectConfirm, $value );
 70+ }
 71+
6772 public function getRefId() {
6873 return $this->refid;
6974 }
@@ -312,6 +317,11 @@
313318 } elseif ( $this->getAction() === 'reject' ) {
314319 $newRev = Revision::newFromTitle( $this->page, $this->oldid );
315320 $oldRev = Revision::newFromTitle( $this->page, $this->refid );
 321+
 322+ if( !$this->rejectConfirm ) {
 323+ $this->rejectConfirmationForm( $oldRev, $newRev );
 324+ return false;
 325+ }
316326 # Do not mess with archived/deleted revisions
317327 if ( is_null( $oldRev ) || $oldRev->mDeleted ) {
318328 return 'review_bad_oldid';
@@ -988,6 +998,64 @@
989999 return $form;
9901000 }
9911001
 1002+ /**
 1003+ * Output the "are you sure you want to reject this" form
 1004+ *
 1005+ * A bit hacky, but we don't have a way to pass more complicated
 1006+ * UI things back up, since RevisionReview expects either true
 1007+ * or a string message key
 1008+ */
 1009+ private function rejectConfirmationForm( Revision $oldRev, $newRev ) {
 1010+ global $wgOut;
 1011+
 1012+ $thisPage = SpecialPage::getTitleFor( 'RevisionReview' );
 1013+
 1014+ $permaLink = $oldRev->getTitle()->getFullURL( 'oldid=' . $oldRev->getId() );
 1015+ $wgOut->addWikiMsg( 'revreview-reject-text', $permaLink );
 1016+
 1017+ $thisPage->skin = $this->user->getSkin();
 1018+ $dbr = wfGetDB( DB_SLAVE );
 1019+ $oldid = $dbr->addQuotes( $oldRev->getId() );
 1020+ $res = $dbr->select( 'revision', 'rev_id',
 1021+ array( 'rev_id > ' . $oldid, 'rev_page' => $oldRev->getPage() ),
 1022+ __METHOD__
 1023+ );
 1024+
 1025+ $ids = array();
 1026+ foreach( $res as $r ) {
 1027+ $ids[] = $r->rev_id;
 1028+ }
 1029+
 1030+ $list = new RevDel_RevisionList( $thisPage, $oldRev->getTitle(), $ids );
 1031+ for ( $list->reset(); $list->current(); $list->next() ) {
 1032+ $item = $list->current();
 1033+ if ( $item->canView() ) {
 1034+ $wgOut->addHTML( $item->getHTML() );
 1035+ }
 1036+ }
 1037+ $form = Html::openElement( 'form',
 1038+ array( 'method' => 'POST', 'action' => $thisPage->getFullUrl() )
 1039+ );
 1040+ $form .= Html::hidden( 'action', 'reject' );
 1041+ $form .= Html::hidden( 'wpReject', 1 );
 1042+ $form .= Html::hidden( 'wpRejectConfirm', 1 );
 1043+ $form .= Html::hidden( 'oldid', $this->oldid );
 1044+ $form .= Html::hidden( 'refid', $this->refid );
 1045+ $form .= Html::hidden( 'target', $oldRev->getTitle()->getPrefixedDBKey() );
 1046+ $form .= Html::hidden( 'wpEditToken', $this->user->editToken() );
 1047+ $form .= "<br />";
 1048+
 1049+ $defaultSummary = wfMsg( 'revreview-reject-default-summary',
 1050+ $newRev->getUserText(), $oldRev->getId(), $oldRev->getUserText() );
 1051+ $form .= Xml::inputLabel( wfMsg( 'revreview-reject-summary' ), 'wpReason',
 1052+ 'wpReason', 120, $defaultSummary ) . "<br />";
 1053+ $form .= Html::input( 'wpSubmit', wfMsg( 'revreview-reject-confirm' ), 'submit' );
 1054+ $form .= Html::input( 'wpCancel', wfMsg( 'revreview-reject-cancel' ),
 1055+ 'button', array( 'onClick' => 'history.back();' ) );
 1056+ $form .= Html::closeElement( 'form' );
 1057+ $wgOut->addHtml( $form );
 1058+ }
 1059+
9921060 private function getSpecialLinks() {
9931061 $s = '<p>' . wfMsg( 'returnto',
9941062 $this->skin->makeLinkObj( SpecialPage::getTitleFor( 'UnreviewedPages' ) ) ) . '</p>';
Index: trunk/extensions/FlaggedRevs/specialpages/RevisionReview_body.php
@@ -46,6 +46,7 @@
4747 $form->setApprove( $wgRequest->getCheck( 'wpApprove' ) );
4848 $form->setUnapprove( $wgRequest->getCheck( 'wpUnapprove' ) );
4949 $form->setReject( $wgRequest->getCheck( 'wpReject' ) );
 50+ $form->setRejectConfirm( $wgRequest->getBool( 'wpRejectConfirm' ) );
5051 # Rev ID
5152 $form->setOldId( $wgRequest->getInt( 'oldid' ) );
5253 $form->setRefId( $wgRequest->getInt( 'refid' ) );
@@ -104,7 +105,9 @@
105106 } elseif ( $form->getAction() === 'reject' ) {
106107 $wgOut->redirect( $this->page->getFullUrl() );
107108 }
108 - // Failure for flagging or unflagging
 109+ } elseif( $status === false ) {
 110+ // Reject confirmation screen. HACKY :(
 111+ return;
109112 } else {
110113 if ( $status === 'review_denied' ) {
111114 $wgOut->permissionRequired( 'badaccess-group0' ); // protected?

Follow-up revisions

RevisionCommit summaryAuthorDate
r76692First followup to r75408, sanity check on result objectdemon18:09, 15 November 2010
r76962Message cleanup for r75408:...demon21:25, 18 November 2010
r77007Follow ups for r76962 and r75408:...aaron06:16, 19 November 2010

Comments

#Comment by Aaron Schulz (talk | contribs)   19:51, 27 October 2010

A few quick things:

  • The message doesn't handle reverting multiple authors.
  • Perhaps the message could also list the number of edits reverted.
  • The "comment" edit summary doesn't carry over to the confirmation. Maybe it can be appended after a colon?
  • Some conflict handling is needed (edit made before you click "reject" or "reject these changes").
  • This fatals out if fails if $res from the query empty (another RevDel list side effect).
  • When rejected edits other than the top X, the list and summary are wrong. It would be nice to support this.
#Comment by RobLa (talk | contribs)   17:42, 15 November 2010

Marking "fixme" so that we address Aaron's comments

#Comment by 😂 (talk | contribs)   21:27, 18 November 2010

See two followups, should handle items 1, 2, 5 and 6.

Status & tagging log