r60878 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r60877‎ | r60878 | r60879 >
Date:21:24, 9 January 2010
Author:aaron
Status:ok
Tags:
Comment:
* Display redirects normally for redirect=no&stable=1 URLs (bug 22036)
* Unified displayTag() calls to one hook for visual consistency
* Cleaned up/renamed getReviewNotes()
* Tweaked revreview-locked msg
* Removed unused global
Modified paths:
  • /trunk/extensions/FlaggedRevs/FlaggedArticleView.php (modified) (history)
  • /trunk/extensions/FlaggedRevs/FlaggedRevs.class.php (modified) (history)
  • /trunk/extensions/FlaggedRevs/FlaggedRevs.hooks.php (modified) (history)
  • /trunk/extensions/FlaggedRevs/FlaggedRevs.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/FlaggedRevs.php
@@ -467,7 +467,7 @@
468468 $wgHooks['ArticleSaveComplete'][] = 'FlaggedRevsHooks::maybeNullEditReview';
469469
470470 # Add CSS/JS as needed
471 -$wgHooks['BeforePageDisplay'][] = 'FlaggedRevsHooks::injectStyleAndJS';
 471+$wgHooks['BeforePageDisplay'][] = 'FlaggedRevsHooks::onBeforePageDisplay';
472472 $wgHooks['MakeGlobalVariablesScript'][] = 'FlaggedRevsHooks::injectGlobalJSVars';
473473
474474 # Extra cache updates for stable versions
Index: trunk/extensions/FlaggedRevs/language/FlaggedRevs.i18n.php
@@ -224,8 +224,8 @@
225225
226226 'revreview-locked-title' => 'Edits must be reviewed before being published on this page.',
227227 'revreview-unlocked-title' => 'Edits do not require review before being published on this page.',
228 - 'revreview-locked' => '\'\'\'Edits must be [[{{MediaWiki:Validationpage}}|reviewed]] before being published on this page.\'\'\'',
229 - 'revreview-unlocked' => 'Edits do not require [[{{MediaWiki:Validationpage}}|review]] before being published on this page.',
 228+ 'revreview-locked' => '\'\'\'Note:\'\'\' Edits must be [[{{MediaWiki:Validationpage}}|reviewed]] before being published on this page.',
 229+ 'revreview-unlocked' => '\'\'\'Note:\'\'\' Edits do not require [[{{MediaWiki:Validationpage}}|review]] before being published on this page.',
230230
231231 'revreview-ak-review' => 's', # do not translate or duplicate this message to other languages
232232 'accesskey-ca-current' => 'v', # do not translate or duplicate this message to other languages
Index: trunk/extensions/FlaggedRevs/FlaggedRevs.class.php
@@ -1541,7 +1541,11 @@
15421542 $sv = FlaggedRevision::newFromStable( $article->getTitle(), FR_MASTER/*consistent*/ );
15431543 if( $sv && $sv->getRevId() == $rev->getId() ) {
15441544 global $wgMemc;
1545 - # Update stable cache
 1545+ # Update stable page cache. Don't cache redirects;
 1546+ # it would go unused and complicate things.
 1547+ if( !Title::newFromRedirect( $text ) ) {
 1548+ FlaggedRevs::updatePageCache( $article, $wgUser, $stableOutput );
 1549+ }
15461550 self::updatePageCache( $article, $user, $poutput );
15471551 # Update page tracking fields
15481552 self::updateStableVersion( $article, $rev, $rev->getId() );
Index: trunk/extensions/FlaggedRevs/specialpages/RevisionReview_body.php
@@ -512,7 +512,8 @@
513513 # Set our versioning params cache
514514 FlaggedRevs::setIncludeVersionCache( $rev->getId(), $tmpParams, $imgParams );
515515 # Parse the text and check if all templates/files match up
516 - $stableOutput = FlaggedRevs::parseStableText( $article, $rev->getText(), $rev->getId() );
 516+ $text = $rev->getText();
 517+ $stableOutput = FlaggedRevs::parseStableText( $article, $text, $rev->getId() );
517518 $err =& $stableOutput->fr_includeErrors;
518519 if( !$noMatch ) { // template/files must all be specified
519520 if( !empty($err)
@@ -592,8 +593,11 @@
593594 if( $sv && $sv->getRevId() == $rev->getId() ) {
594595 global $wgParserCacheExpireTime;
595596 $this->page->invalidateCache();
596 - # Update stable cache with the revision we reviewed
597 - FlaggedRevs::updatePageCache( $article, $wgUser, $stableOutput );
 597+ # Update stable cache with the revision we reviewed.
 598+ # Don't cache redirects; it would go unused and complicate things.
 599+ if( !Title::newFromRedirect( $text ) ) {
 600+ FlaggedRevs::updatePageCache( $article, $wgUser, $stableOutput );
 601+ }
598602 # We can set the sync cache key already
599603 $includesSynced = true;
600604 if( $poutput->fr_newestImageTime > $stableOutput->fr_newestImageTime ) {
Index: trunk/extensions/FlaggedRevs/FlaggedRevs.hooks.php
@@ -75,7 +75,7 @@
7676 * Add FlaggedRevs css for relevant special pages.
7777 */
7878 public static function InjectStyleForSpecial() {
79 - global $wgTitle, $wgOut, $wgUser;
 79+ global $wgTitle, $wgOut;
8080 if( empty($wgTitle) || $wgTitle->getNamespace() !== NS_SPECIAL ) {
8181 return true;
8282 }
@@ -95,6 +95,18 @@
9696 return true;
9797 }
9898
 99+ public static function onBeforePageDisplay() {
 100+ global $wgOut;
 101+ if( $wgOut->isArticleRelated() ) {
 102+ $view = FlaggedArticleView::singleton();
 103+ $view->displayTag(); // show notice bar/icon in subtitle
 104+ self::injectStyleAndJS(); // full CSS/JS
 105+ } else {
 106+ self::InjectStyleForSpecial(); // try special page CSS
 107+ }
 108+ return true;
 109+ }
 110+
99111 public static function markUnderReview( $output, $article, $title, $user, $request ) {
100112 $action = $request->getVal( 'action', 'view' );
101113 $reviewing = ( $action == 'history' ); // default
Index: trunk/extensions/FlaggedRevs/FlaggedArticleView.php
@@ -117,7 +117,7 @@
118118 /**
119119 * Output review notice
120120 */
121 - protected function displayTag() {
 121+ public function displayTag() {
122122 global $wgOut, $wgRequest;
123123 $this->load();
124124 // UI may be limited to unobtrusive patrolling system
@@ -232,8 +232,6 @@
233233 if( is_null($frev) ) {
234234 # Add "no reviewed version" tag, but not for printable output
235235 $this->showUnreviewedPage( $tag, $prot );
236 - # Show notice bar/icon
237 - $this->displayTag();
238236 return true;
239237 }
240238 # Get flags and date
@@ -275,8 +273,6 @@
276274 "$tag</div>";
277275 $this->reviewNotice .= $tag;
278276 }
279 - # Show notice bar/icon
280 - $this->displayTag();
281277
282278 return true;
283279 }
@@ -328,7 +324,7 @@
329325 # Get stable version sync status
330326 $synced = FlaggedRevs::stableVersionIsSynced( $srev, $this->article );
331327 if( $synced ) {
332 - $this->getReviewNotes( $srev ); // Still the same
 328+ $this->setReviewNotes( $srev ); // Still the same
333329 } else {
334330 $this->maybeShowTopDiff( $srev, $quality ); // user may want diff (via prefs)
335331 }
@@ -464,7 +460,7 @@
465461 }
466462 }
467463 # Output HTML
468 - $this->getReviewNotes( $frev );
 464+ $this->setReviewNotes( $frev );
469465 $wgOut->addParserOutput( $parserOut );
470466 # Index the stable version only
471467 $wgOut->setRobotPolicy( 'noindex,nofollow' );
@@ -488,12 +484,19 @@
489485 $quality = FlaggedRevs::isQuality( $flags );
490486 $pristine = FlaggedRevs::isPristine( $flags );
491487 # Get parsed stable version
 488+ $redirHtml = '';
492489 $parserOut = FlaggedRevs::getPageCache( $this->article, $wgUser );
493490 if( $parserOut == false ) {
494491 $text = $srev->getRevText();
495 - $parserOut = FlaggedRevs::parseStableText( $this->article, $text, $srev->getRevId() );
496 - # Update the stable version cache
497 - FlaggedRevs::updatePageCache( $this->article, $wgUser, $parserOut );
 492+ # Check if this is a redirect...
 493+ $rTarget = $this->article->followRedirectText( $text );
 494+ if( $rTarget ) {
 495+ $redirHtml = $this->article->viewRedirect( $rTarget );
 496+ } else {
 497+ $parserOut = FlaggedRevs::parseStableText( $this->article, $text, $srev->getRevId() );
 498+ # Update the stable version cache
 499+ FlaggedRevs::updatePageCache( $this->article, $wgUser, $parserOut );
 500+ }
498501 }
499502 $synced = FlaggedRevs::stableVersionIsSynced( $srev, $this->article, $parserOut, null );
500503 # Construct some tagging
@@ -537,8 +540,12 @@
538541 }
539542 }
540543 # Output HTML
541 - $this->getReviewNotes( $srev );
542 - $wgOut->addParserOutput( $parserOut );
 544+ $this->setReviewNotes( $srev );
 545+ if( $redirHtml != '' ) {
 546+ $wgOut->addHtml( $redirHtml );
 547+ } else {
 548+ $wgOut->addParserOutput( $parserOut );
 549+ }
543550 }
544551
545552 /**
@@ -1033,16 +1040,15 @@
10341041 * @param FlaggedRevision $frev
10351042 * @return string, revision review notes
10361043 */
1037 - public function getReviewNotes( $frev ) {
 1044+ public function setReviewNotes( $frev ) {
10381045 global $wgUser;
10391046 $this->load();
1040 - if( FlaggedRevs::allowComments() && $frev && $frev->getComment() ) {
1041 - $notes = "<br /><div class='flaggedrevs_notes plainlinks'>";
1042 - $notes .= wfMsgExt('revreview-note', array('parseinline'),
 1047+ if( $frev && FlaggedRevs::allowComments() && $frev->getComment() != '' ) {
 1048+ $this->reviewNotes = "<br /><div class='flaggedrevs_notes plainlinks'>";
 1049+ $this->reviewNotes .= wfMsgExt('revreview-note', array('parseinline'),
10431050 User::whoIs( $frev->getUser() ) );
1044 - $notes .= '<br /><i>' . $wgUser->getSkin()->formatComment( $frev->getComment() ) .
1045 - '</i></div>';
1046 - $this->reviewNotes = $notes;
 1051+ $this->reviewNotes .= '<br /><i>' .
 1052+ $wgUser->getSkin()->formatComment( $frev->getComment() ) . '</i></div>';
10471053 }
10481054 }
10491055

Follow-up revisions

RevisionCommit summaryAuthorDate
r60879Follow up r60878: same for old reviewed revs.aaron21:37, 9 January 2010
r61744Fixed ridiculous (copy paste?) mistake from r60878aaron15:18, 31 January 2010

Status & tagging log