r85743 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r85742‎ | r85743 | r85744 >
Date:05:50, 10 April 2011
Author:aaron
Status:ok
Tags:
Comment:
* Don't show reject button if there are no text changes
* Renamed $id => $revId
* Other small code cleanups
Modified paths:
  • /trunk/extensions/FlaggedRevs/business/RevisionReviewForm.php (modified) (history)
  • /trunk/extensions/FlaggedRevs/presentation/FlaggedArticleView.php (modified) (history)
  • /trunk/extensions/FlaggedRevs/presentation/RevisionReviewFormGUI.php (modified) (history)

Diff [purge]

Index: trunk/extensions/FlaggedRevs/business/RevisionReviewForm.php
@@ -289,6 +289,7 @@
290290 return 'review_cannot_reject'; // not really a use case
291291 }
292292 $article = new Article( $this->page );
 293+ # Get text with changes after $oldRev up to and including $newRev removed
293294 $new_text = $article->getUndoText( $newRev, $oldRev );
294295 if ( $new_text === false ) {
295296 return 'review_cannot_undo';
Index: trunk/extensions/FlaggedRevs/presentation/RevisionReviewFormGUI.php
@@ -6,7 +6,8 @@
77 */
88 class RevisionReviewFormGUI {
99 protected $user, $article, $rev;
10 - protected $refId = 0, $topNotice = '';
 10+ protected $refRev = null;
 11+ protected $topNotice = '';
1112 protected $templateIDs = null, $imageSHA1Keys = null;
1213
1314 /**
@@ -22,13 +23,13 @@
2324 }
2425
2526 /*
26 - * If $refId > 0:
27 - * (a) Show "reject" button
28 - * (b) default the rating tags to those of $rev if it was flagged
29 - * @param int $refId Left side version ID for diffs, $rev is the right rev
 27+ * Call this only when the form is shown on a diff:
 28+ * (a) Shows the "reject" button
 29+ * (b) Default the rating tags to those of $this->rev (if flagged)
 30+ * @param Revision $refRev Old revision for diffs ($this->rev is the new rev)
3031 */
31 - public function setDiffLeftId( $refId ) {
32 - $this->refId = $refId;
 32+ public function setDiffPriorRev( Revision $refRev ) {
 33+ $this->refRev = $refRev;
3334 }
3435
3536 /*
@@ -54,7 +55,7 @@
5556 */
5657 public function getHtml() {
5758 global $wgOut, $wgLang, $wgParser, $wgEnableParserCache;
58 - $id = $this->rev->getId();
 59+ $revId = $this->rev->getId();
5960 if ( $this->rev->isDeleted( Revision::DELETED_TEXT ) ) {
6061 return array( '', 'review_bad_oldid' ); # The revision must be valid and public
6162 }
@@ -62,20 +63,21 @@
6364
6465 $srev = $article->getStableRev();
6566 # See if the version being displayed is flagged...
66 - if ( $id == $article->getStable() ) {
 67+ if ( $revId == $article->getStable() ) {
6768 $frev = $srev; // avoid query
6869 } else {
69 - $frev = FlaggedRevision::newFromTitle( $article->getTitle(), $id );
 70+ $frev = FlaggedRevision::newFromTitle( $article->getTitle(), $revId );
7071 }
7172 $oldFlags = $frev
7273 ? $frev->getTags() // existing tags
7374 : FlaggedRevs::quickTags( FR_CHECKED ); // basic tags
7475 $reviewTime = $frev ? $frev->getTimestamp() : ''; // last review of rev
7576
 77+ $priorRevId = $this->refRev ? $this->refRev->getId() : 0;
7678 # If we are reviewing updates to a page, start off with the stable revision's
7779 # flags. Otherwise, we just fill them in with the selected revision's flags.
7880 # @TODO: do we want to carry over info for other diffs?
79 - if ( $srev && $srev->getRevId() == $this->refId ) { // diff-to-stable
 81+ if ( $srev && $srev->getRevId() == $priorRevId ) { // diff-to-stable
8082 $flags = $srev->getTags();
8183 # Check if user is allowed to renew the stable version.
8284 # If not, then get the flags for the new revision itself.
@@ -83,7 +85,7 @@
8486 $flags = $oldFlags;
8587 }
8688 # Re-review button is need for template/file only review case
87 - $reviewIncludes = ( $srev->getRevId() == $id && !$article->stableVersionIsSynced() );
 89+ $reviewIncludes = ( $srev->getRevId() == $revId && !$article->stableVersionIsSynced() );
8890 } else { // views
8991 $flags = $oldFlags;
9092 $reviewIncludes = false; // re-review button not needed
@@ -112,18 +114,18 @@
113115 $form .= Xml::closeElement( 'legend' ) . "\n";
114116 # Show explanatory text
115117 $form .= $this->topNotice;
116 - # Show possible conflict warning msg
117 - if ( $this->refId ) {
 118+ # Show possible conflict warning msg...
 119+ if ( $priorRevId ) {
118120 list( $u, $ts ) =
119 - FRUserActivity::getUserReviewingDiff( $this->refId, $this->rev->getId() );
 121+ FRUserActivity::getUserReviewingDiff( $priorRevId, $this->rev->getId() );
120122 } else {
121123 list( $u, $ts ) = FRUserActivity::getUserReviewingPage( $this->rev->getPage() );
122124 }
123125 if ( $u !== null && $u != $this->user->getName() ) {
124 - $msg = $this->refId ? 'revreview-poss-conflict-c' : 'revreview-poss-conflict-p';
 126+ $msg = $priorRevId ? 'revreview-poss-conflict-c' : 'revreview-poss-conflict-p';
125127 $form .= '<p><span class="fr-under-review">' .
126 - wfMsgExt( $msg, 'parseinline', $u,
127 - $wgLang->date( $ts, true ), $wgLang->time( $ts, true ) ) .
 128+ wfMsgExt( $msg, 'parseinline',
 129+ $u, $wgLang->date( $ts, true ), $wgLang->time( $ts, true ) ) .
128130 '</span></p>';
129131 }
130132
@@ -158,10 +160,7 @@
159161 array( 'class' => 'fr-comment-box' ) ) . "&#160;&#160;&#160;</span>";
160162 }
161163 # Determine if there will be reject button
162 - $rejectId = 0;
163 - if ( $this->refId == $article->getStable() && $id != $this->refId ) {
164 - $rejectId = $this->refId; // left rev must be stable and right one newer
165 - }
 164+ $rejectId = $this->rejectRefRevId();
166165 # Add the submit buttons
167166 $form .= self::submitButtons( $rejectId, $frev, (bool)$disabled, $reviewIncludes );
168167 # Show stability log if there is anything interesting...
@@ -178,8 +177,8 @@
179178 # Hidden params
180179 $form .= Html::hidden( 'title', $reviewTitle->getPrefixedText() ) . "\n";
181180 $form .= Html::hidden( 'target', $article->getTitle()->getPrefixedDBKey() ) . "\n";
182 - $form .= Html::hidden( 'refid', $this->refId ) . "\n";
183 - $form .= Html::hidden( 'oldid', $id ) . "\n";
 181+ $form .= Html::hidden( 'refid', $priorRevId ) . "\n";
 182+ $form .= Html::hidden( 'oldid', $revId ) . "\n";
184183 $form .= Html::hidden( 'action', 'submit' ) . "\n";
185184 $form .= Html::hidden( 'wpEditToken', $this->user->editToken() ) . "\n";
186185 $form .= Html::hidden( 'changetime', $reviewTime,
@@ -190,7 +189,7 @@
191190 $form .= Html::hidden( 'fileVersion', $fileVersion ) . "\n";
192191 # Special token to discourage fiddling...
193192 $checkCode = RevisionReviewForm::validationKey(
194 - $templateParams, $imageParams, $fileVersion, $id
 193+ $templateParams, $imageParams, $fileVersion, $revId
195194 );
196195 $form .= Html::hidden( 'validatedParams', $checkCode ) . "\n";
197196
@@ -200,6 +199,22 @@
201200 return array( $form, true /* ok */ );
202201 }
203202
 203+ /*
 204+ * If the REJECT button should show then get the ID of the last good rev
 205+ * @return int
 206+ */
 207+ protected function rejectRefRevId() {
 208+ if ( $this->refRev ) {
 209+ $priorId = $this->refRev->getId();
 210+ if ( $priorId == $this->article->getStable() && $priorId != $this->rev->getId() ) {
 211+ if ( $this->rev->getText() != $this->refRev->getText() ) {
 212+ return $priorId; // left rev must be stable and right one newer
 213+ }
 214+ }
 215+ }
 216+ return 0;
 217+ }
 218+
204219 /**
205220 * @param User $user
206221 * @param array $flags, selected flags
Index: trunk/extensions/FlaggedRevs/presentation/FlaggedArticleView.php
@@ -5,7 +5,7 @@
66 class FlaggedArticleView {
77 protected $article = null;
88
9 - protected $diffRevs = null;
 9+ protected $diffRevs = null; // assoc array of old and new Revisions for diffs
1010 protected $isReviewableDiff = false;
1111 protected $isDiffFromStable = false;
1212 protected $isMultiPageDiff = false;
@@ -1072,8 +1072,10 @@
10731073 # Build the review form as needed
10741074 if ( $rev && ( !$this->diffRevs || $this->isReviewableDiff ) ) {
10751075 $form = new RevisionReviewFormGUI( $wgUser, $this->article, $rev );
1076 - # Tag default and "reject" button depend on context
1077 - $form->setDiffLeftId( $this->diffRevs['old'] );
 1076+ # Default tags and existence of "reject" button depend on context
 1077+ if ( $this->diffRevs ) {
 1078+ $form->setDiffPriorRev( $this->diffRevs['old'] );
 1079+ }
10781080 # Review notice box goes in top of form
10791081 $form->setTopNotice( $this->diffNoticeBox );
10801082 # $wgOut may not already have the inclusion IDs, such as for diffonly=1.
@@ -1579,7 +1581,7 @@
15801582 $this->isReviewableDiff = true;
15811583 }
15821584 }
1583 - $this->diffRevs = array( 'old' => $oldRev->getId(), 'new' => $newRev->getId() );
 1585+ $this->diffRevs = array( 'old' => $oldRev, 'new' => $newRev );
15841586 }
15851587 return true;
15861588 }

Follow-up revisions

RevisionCommit summaryAuthorDate
r85745Follow-up r85743: use rawText functionaaron06:25, 10 April 2011

Status & tagging log