r68503 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r68502‎ | r68503 | r68504 >
Date:03:24, 24 June 2010
Author:aaron
Status:deferred
Tags:
Comment:
* split off editRequiresReview/editWillBeAutoreviewed from editWillRequireReview
* (bug 24085) Show wpReviewEdit checkbox when saving a reviewed page with review but not autoreview rights
* cache $frev for editRequiresReview
Modified paths:
  • /trunk/extensions/FlaggedRevs/FlaggedArticle.php (modified) (history)
  • /trunk/extensions/FlaggedRevs/FlaggedArticleView.php (modified) (history)
  • /trunk/extensions/FlaggedRevs/language/FlaggedRevs.i18n.php (modified) (history)

Diff [purge]

Index: trunk/extensions/FlaggedRevs/language/FlaggedRevs.i18n.php
@@ -116,6 +116,8 @@
117117 'revreview-check-flag-p-title' => 'Accept all the currently pending changes along with your own edit. Only use this if you have already seen the entire pending changes diff.',
118118 'revreview-check-flag-u' => 'Accept this unreviewed page',
119119 'revreview-check-flag-u-title' => 'Accept this version of the page. Only use this if you have already seen the entire page.',
 120+ 'revreview-check-flag-y' => 'Accept these changes',
 121+ 'revreview-check-flag-y-title' => 'Accept all the changes that you have made in this edit.',
120122 'revreview-submitedit' => 'Submit changes',
121123 'revreview-submitedit-title' => 'Submit your changes for review',
122124 'revreview-edited' => '\'\'\'Your changes will be displayed to readers once an authorized user reviews them. ([[{{MediaWiki:Validationpage}}|help]])\'\'\'
Index: trunk/extensions/FlaggedRevs/FlaggedArticle.php
@@ -87,7 +87,7 @@
8888 }
8989
9090 /**
91 - * Do edits have to be reviewed before being shown by default?
 91+ * Do edits have to be reviewed before being shown by default (going live)?
9292 * @param int $flags, FR_MASTER
9393 * @return bool
9494 */
Index: trunk/extensions/FlaggedRevs/FlaggedArticleView.php
@@ -1610,45 +1610,76 @@
16111611 }
16121612
16131613 /**
1614 - * If submitting this edit will leave it pending
 1614+ * If this edit will not go live on submit (accounting for wpReviewEdit)
16151615 * @param EditPage $editPage
16161616 * @return bool
16171617 */
16181618 protected function editWillRequireReview( EditPage $editPage ) {
16191619 global $wgRequest;
16201620 $title = $this->article->getTitle(); // convenience
 1621+ if ( !$this->editRequiresReview( $editPage ) ) {
 1622+ return false; // edit will go live immediatly
 1623+ } elseif ( $wgRequest->getCheck( 'wpReviewEdit' ) && $title->userCan( 'review' ) ) {
 1624+ return false; // edit checked off to be reviewed on save
 1625+ }
 1626+ return true; // edit needs review
 1627+ }
 1628+
 1629+ /**
 1630+ * If this edit will not go live on submit unless wpReviewEdit is checked
 1631+ * @param EditPage $editPage
 1632+ * @return bool
 1633+ */
 1634+ protected function editRequiresReview( EditPage $editPage ) {
 1635+ $title = $this->article->getTitle(); // convenience
16211636 if ( !$this->article->editsRequireReview() ) {
16221637 return false; // edits go live immediatly
1623 - } elseif ( $wgRequest->getCheck( 'wpReviewEdit' ) && $title->userCan( 'review' ) ) {
1624 - return false; // edit will checked off to be reviewed
 1638+ } elseif ( $this->editWillBeAutoreviewed( $editPage ) ) {
 1639+ return false; // edit will be autoreviewed anyway
16251640 }
 1641+ return true; // edit needs review
 1642+ }
 1643+
 1644+ /**
 1645+ * If this edit will be auto-reviewed on submit
 1646+ * Note: checking wpReviewEdit does not count as auto-reviewed
 1647+ * @param EditPage $editPage
 1648+ * @return bool
 1649+ */
 1650+ protected function editWillBeAutoreviewed( EditPage $editPage ) {
 1651+ $title = $this->article->getTitle(); // convenience
 1652+ if ( !$this->article->isReviewable() ) {
 1653+ return false;
 1654+ }
16261655 if ( $title->userCan( 'autoreview' ) ) {
16271656 if ( FlaggedRevs::autoReviewNewPages() && !$this->article->exists() ) {
1628 - return false; // edit will be autoreviewed anyway
 1657+ return true; // edit will be autoreviewed
16291658 }
1630 - $frev = FlaggedRevision::newFromTitle( $title, self::getBaseRevId( $editPage ) );
1631 - if ( $frev ) {
1632 - return false; // edit will be autoreviewed anyway
 1659+ if ( !isset( $editPage->fr_baseFRev ) ) {
 1660+ $baseRevId = self::getBaseRevId( $editPage );
 1661+ $editPage->fr_baseFRev = FlaggedRevision::newFromTitle( $title, $baseRevId );
16331662 }
 1663+ if ( $editPage->fr_baseFRev ) {
 1664+ return true; // edit will be autoreviewed
 1665+ }
16341666 }
1635 - return true; // edit needs review
 1667+ return false; // edit won't be autoreviewed
16361668 }
16371669
16381670 /**
1639 - * Add a "review pending changes" checkbox to the edit form if:
 1671+ * Add a "review pending changes" checkbox to the edit form iff:
16401672 * (a) there are currently any revisions pending (bug 16713)
16411673 * (b) this is an unreviewed page (bug 23970)
16421674 */
16431675 public function addReviewCheck( EditPage $editPage, array &$checkboxes, &$tabindex ) {
1644 - global $wgUser, $wgRequest;
1645 - if ( !$this->article->isReviewable()
1646 - || !$this->article->getTitle()->userCan( 'review' )
1647 - || ( $this->article->getStable() && !$this->article->revsArePending() )
1648 - ) {
 1676+ global $wgRequest;
 1677+ $title = $this->article->getTitle(); // convenience
 1678+ if ( !$this->article->isReviewable() || !$title->userCan( 'review' ) ) {
16491679 return true; // not needed
 1680+ } elseif ( $this->editWillBeAutoreviewed( $editPage ) ) {
 1681+ return true; // edit will be auto-reviewed
16501682 }
1651 - $oldid = $wgRequest->getInt( 'baseRevId', $this->article->getLatest() );
1652 - if ( $oldid == $this->article->getLatest() ) {
 1683+ if ( self::getBaseRevId( $editPage ) == $this->article->getLatest() ) {
16531684 # For pages with either no stable version, or an outdated one, let
16541685 # the user decide if he/she wants it reviewed on the spot. One might
16551686 # do this if he/she just saw the diff-to-stable and *then* decided to edit.
@@ -1659,10 +1690,17 @@
16601691 array( 'tabindex' => ++$tabindex, 'id' => 'wpReviewEdit' )
16611692 );
16621693 $attribs = array( 'for' => 'wpReviewEdit' );
1663 - // For pending changes...
 1694+ // For reviewed pages...
16641695 if ( $this->article->getStable() ) {
1665 - $attribs['title'] = wfMsg( 'revreview-check-flag-p-title' );
1666 - $labelMsg = wfMsgExt( 'revreview-check-flag-p', 'parseinline' );
 1696+ // For pending changes...
 1697+ if ( $this->article->revsArePending() ) {
 1698+ $attribs['title'] = wfMsg( 'revreview-check-flag-p-title' );
 1699+ $labelMsg = wfMsgExt( 'revreview-check-flag-p', 'parseinline' );
 1700+ // For just the user's changes...
 1701+ } else {
 1702+ $attribs['title'] = wfMsg( 'revreview-check-flag-y-title' );
 1703+ $labelMsg = wfMsgExt( 'revreview-check-flag-y', 'parseinline' );
 1704+ }
16671705 // For unreviewed pages...
16681706 } else {
16691707 $attribs['title'] = wfMsg( 'revreview-check-flag-u-title' );
@@ -1673,7 +1711,7 @@
16741712 }
16751713 return true;
16761714 }
1677 -
 1715+
16781716 /**
16791717 * (a) Add a hidden field that has the rev ID the text is based off.
16801718 * (b) If an edit was undone, add a hidden field that has the rev ID of that edit.
@@ -1692,7 +1730,7 @@
16931731
16941732 /**
16951733 * Guess the rev ID the text of this form is based off
1696 - * Note: baseRevId trusted for Reviewers - text checked for others.
 1734+ * Note: baseRevId trusted for Reviewers - check text for others.
16971735 * @return int
16981736 */
16991737 protected static function getBaseRevId( EditPage $editPage ) {

Status & tagging log