r68067 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r68066‎ | r68067 | r68068 >
Date:12:39, 15 June 2010
Author:aaron
Status:deferred
Tags:
Comment:
* Removed garbage [unreviewed page] items in RCL (bug 23968)
* Cleaned up useless code in addReviewCheck(). Changed isAllowed() -> userCan().
* Removed unused params to stableVersionIsSynced() call
* Added inclusionSetting() checks to findPendingTemplateChanges()/findPendingFileChanges()
* Updated doc comments
Modified paths:
  • /trunk/extensions/FlaggedRevs/FlaggedArticleView.php (modified) (history)
  • /trunk/extensions/FlaggedRevs/FlaggedRevision.php (modified) (history)
  • /trunk/extensions/FlaggedRevs/FlaggedRevs.hooks.php (modified) (history)

Diff [purge]

Index: trunk/extensions/FlaggedRevs/FlaggedRevision.php
@@ -409,6 +409,7 @@
410410 }
411411
412412 /**
 413+ * Get original template versions at time of review
413414 * @return Array template versions (ns -> dbKey -> rev id)
414415 */
415416 public function getTemplateVersions() {
@@ -430,6 +431,7 @@
431432 }
432433
433434 /**
 435+ * Get original template versions at time of review
434436 * @return Array file versions (dbKey -> sha1)
435437 */
436438 public function getFileVersions() {
@@ -449,12 +451,18 @@
450452
451453 /*
452454 * Fetch pending template changes for this reviewed page version.
453 - * For each template, the version used is newest( stable rev, rev at time of review ).
 455+ * For each template, the version used is:
 456+ * (a) (the latest rev) if FR_INCLUDES_CURRENT
 457+ * (b) newest( stable rev, rev at time of review ) if FR_INCLUDES_STABLE
 458+ * (c) ( rev at time of review ) if FR_INCLUDES_FREEZE
454459 * Pending changes exist if the latest version of the template is newer than this.
455460 *
456461 * @return Array of (template title, rev ID in reviewed version) tuples
457462 */
458463 public function findPendingTemplateChanges() {
 464+ if ( FlaggedRevs::inclusionSetting() == FR_INCLUDES_CURRENT ) {
 465+ return array(); // short-circuit
 466+ }
459467 $dbr = wfGetDB( DB_SLAVE );
460468 $ret = $dbr->select( array( 'flaggedtemplates', 'page', 'flaggedpages' ),
461469 array( 'ft_namespace', 'ft_title', 'fp_stable', 'ft_tmp_rev_id', 'page_latest' ),
@@ -470,8 +478,12 @@
471479 while ( $row = $dbr->fetchObject( $ret ) ) {
472480 $title = Title::makeTitleSafe( $row->ft_namespace, $row->ft_title );
473481 $revIdDraft = (int)$row->page_latest; // may be NULL
474 - # Select newest of (stable rev, rev when reviewed) when parsing
475 - $revIdStable = max( $row->fp_stable, $row->ft_tmp_rev_id );
 482+ if ( FlaggedRevs::inclusionSetting() == FR_INCLUDES_STABLE ) {
 483+ # Select newest of (stable rev, rev when reviewed) when parsing
 484+ $revIdStable = max( $row->fp_stable, $row->ft_tmp_rev_id );
 485+ } else {
 486+ $revIdStable = (int)$row->ft_tmp_rev_id;
 487+ }
476488 # Compare to current...
477489 $deleted = ( !$revIdDraft && $revIdStable ); // later deleted
478490 $updated = ( $revIdDraft && $revIdDraft > $revIdStable ); // updated/created
@@ -484,13 +496,19 @@
485497
486498 /*
487499 * Fetch pending file changes for this reviewed page version.
488 - * For each file, the version used is newest( stable rev, rev at time of review ).
 500+ * For each file, the version used is:
 501+ * (a) (the latest rev) if FR_INCLUDES_CURRENT
 502+ * (b) newest( stable rev, rev at time of review ) if FR_INCLUDES_STABLE
 503+ * (c) ( rev at time of review ) if FR_INCLUDES_FREEZE
489504 * Pending changes exist if the latest version of the file is newer than this.
490505 * @TODO: skip commons images, deliberately? (bug 15748).
491506 *
492507 * @return Array of (file title, MW file timestamp in reviewed version) tuples
493508 */
494509 public function findPendingFileChanges() {
 510+ if ( FlaggedRevs::inclusionSetting() == FR_INCLUDES_CURRENT ) {
 511+ return array(); // short-circuit
 512+ }
495513 $dbr = wfGetDB( DB_SLAVE );
496514 $ret = $dbr->select(
497515 array( 'flaggedimages', 'page', 'flaggedpages', 'flaggedrevs' ),
@@ -509,10 +527,14 @@
510528 while ( $row = $dbr->fetchObject( $ret ) ) {
511529 $title = Title::makeTitleSafe( NS_FILE, $row->fi_name );
512530 $reviewedTS = trim( $row->fi_img_timestamp ); // may be ''/NULL
513 - # Select newest of (stable rev, rev when reviewed) when parsing
514 - $tsStable = $row->fr_img_timestamp >= $reviewedTS
515 - ? $row->fr_img_timestamp
516 - : $reviewedTS;
 531+ if ( FlaggedRevs::inclusionSetting() == FR_INCLUDES_STABLE ) {
 532+ # Select newest of (stable rev, rev when reviewed) when parsing
 533+ $tsStable = $row->fr_img_timestamp >= $reviewedTS
 534+ ? $row->fr_img_timestamp
 535+ : $reviewedTS;
 536+ } else {
 537+ $tsStable = $reviewedTS;
 538+ }
517539 # Compare to current...
518540 $file = wfFindFile( $title ); // current file version
519541 $deleted = ( !$file && $tsStable ); // later deleted
Index: trunk/extensions/FlaggedRevs/FlaggedRevs.hooks.php
@@ -1976,13 +1976,14 @@
19771977 public static function addToChangeListLine( &$list, &$articlelink, &$s, RecentChange &$rc ) {
19781978 $title = $rc->getTitle(); // convenience
19791979 if ( !FlaggedRevs::inReviewNamespace( $title )
1980 - || empty( $rc->mAttribs['rc_this_oldid'] ) )
 1980+ || empty( $rc->mAttribs['rc_this_oldid'] )
 1981+ || !array_key_exists( 'fp_stable', $rc->mAttribs ) )
19811982 {
19821983 return true; // confirm that page is in reviewable namespace
19831984 }
19841985 $rlink = '';
19851986 // page is not reviewed
1986 - if ( empty( $rc->mAttribs['fp_stable'] ) ) {
 1987+ if ( $rc->mAttribs['fp_stable'] == null ) {
19871988 // Is this a config were pages start off reviewable?
19881989 if ( !FlaggedRevs::stableOnlyIfConfigured() ) {
19891990 $rlink = wfMsgHtml( 'revreview-unreviewedpage' );
Index: trunk/extensions/FlaggedRevs/FlaggedArticleView.php
@@ -549,7 +549,7 @@
550550 $parserOut = null;
551551 }
552552 }
553 - $synced = $this->article->stableVersionIsSynced( $parserOut, null );
 553+ $synced = $this->article->stableVersionIsSynced();
554554 # Construct some tagging
555555 if ( !$wgOut->isPrintable() && !( $this->article->lowProfileUI() && $synced ) ) {
556556 $revsSince = $this->article->getPendingRevCount();
@@ -1540,7 +1540,7 @@
15411541 */
15421542 public function addReviewCheck( EditPage $editPage, array &$checkboxes, &$tabindex ) {
15431543 global $wgUser, $wgRequest;
1544 - if ( !$wgUser->isAllowed( 'review' )
 1544+ if ( !$this->article->getTitle()->userCan( 'review' )
15451545 || !$this->article->isReviewable()
15461546 || !$this->article->revsArePending() )
15471547 {
@@ -1548,25 +1548,22 @@
15491549 }
15501550 $oldid = $wgRequest->getInt( 'baseRevId', $this->article->getLatest() );
15511551 if ( $oldid == $this->article->getLatest() ) {
1552 - $srev = $this->article->getStableRev();
15531552 # For pages with either no stable version, or an outdated one, let
15541553 # the user decide if he/she wants it reviewed on the spot. One might
15551554 # do this if he/she just saw the diff-to-stable and *then* decided to edit.
15561555 # Note: check not shown when editing old revisions, which is confusing.
1557 - if ( !$srev || $this->article->revsArePending() ) {
1558 - $checkbox = Xml::check(
1559 - 'wpReviewEdit',
1560 - $wgRequest->getCheck( 'wpReviewEdit' ),
1561 - array( 'tabindex' => ++$tabindex, 'id' => 'wpReviewEdit' )
1562 - );
1563 - $attribs = array(
1564 - 'for' => 'wpReviewEdit',
1565 - 'title' => wfMsg( 'revreview-check-flag-title' )
1566 - );
1567 - $label = Xml::element( 'label', $attribs,
1568 - wfMsgExt( 'revreview-check-flag', 'parseinline' ) );
1569 - $checkboxes['reviewed'] = $checkbox . ' ' . $label;
1570 - }
 1556+ $checkbox = Xml::check(
 1557+ 'wpReviewEdit',
 1558+ $wgRequest->getCheck( 'wpReviewEdit' ),
 1559+ array( 'tabindex' => ++$tabindex, 'id' => 'wpReviewEdit' )
 1560+ );
 1561+ $attribs = array(
 1562+ 'for' => 'wpReviewEdit',
 1563+ 'title' => wfMsg( 'revreview-check-flag-title' )
 1564+ );
 1565+ $label = Xml::element( 'label', $attribs,
 1566+ wfMsgExt( 'revreview-check-flag', 'parseinline' ) );
 1567+ $checkboxes['reviewed'] = $checkbox . ' ' . $label;
15711568 }
15721569 return true;
15731570 }

Follow-up revisions

RevisionCommit summaryAuthorDate
r68068MFT r68067aaron12:43, 15 June 2010

Status & tagging log