r99047 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r99046‎ | r99047 | r99048 >
Date:20:29, 5 October 2011
Author:aaron
Status:resolved
Tags:
Comment:
Made FlaggedPageView extend ContextSource and removed some global usage
Modified paths:
  • /trunk/extensions/FlaggedRevs/presentation/FlaggedPageView.php (modified) (history)

Diff [purge]

Index: trunk/extensions/FlaggedRevs/presentation/FlaggedPageView.php
@@ -2,7 +2,7 @@
33 /**
44 * Class representing a web view of a MediaWiki page
55 */
6 -class FlaggedPageView {
 6+class FlaggedPageView extends ContextSource {
77 protected $out = null;
88 protected $article = null;
99
@@ -50,8 +50,7 @@
5151 if ( $this->article == null ) {
5252 throw new MWException( 'FlaggedPageView has no context article!' );
5353 }
54 - // @TODO: store whole request context
55 - $this->out = RequestContext::getMain()->getOutput();
 54+ $this->out = $this->getOutput(); // convenience
5655 }
5756 }
5857
@@ -84,24 +83,25 @@
8584 * @return bool
8685 */
8786 protected function showingStableAsDefault() {
88 - global $wgUser, $wgRequest;
 87+ $request = $this->getRequest();
 88+ $reqUser = $this->getUser();
8989 $this->load();
9090 # This only applies to viewing the default version of pages...
91 - if ( !$this->isDefaultPageView( $wgRequest ) ) {
 91+ if ( !$this->isDefaultPageView( $request ) ) {
9292 return false;
9393 # ...and the page must be reviewable and have a stable version
9494 } elseif ( !$this->article->getStableRev() ) {
9595 return false;
9696 }
9797 # Check user preferences ("show stable by default?")
98 - $pref = (int)$wgUser->getOption( 'flaggedrevsstable' );
 98+ $pref = (int)$reqUser->getOption( 'flaggedrevsstable' );
9999 if ( $pref == FR_SHOW_STABLE_ALWAYS ) {
100100 return true;
101101 } elseif ( $pref == FR_SHOW_STABLE_NEVER ) {
102102 return false;
103103 }
104104 # Viewer may be in a group that sees the draft by default
105 - if ( $this->userViewsDraftByDefault( $wgUser ) ) {
 105+ if ( $this->userViewsDraftByDefault( $reqUser ) ) {
106106 return false;
107107 }
108108 # Does the stable version override the draft?
@@ -116,15 +116,15 @@
117117 * @return bool
118118 */
119119 protected function showingStableByRequest() {
120 - global $wgRequest;
 120+ $request = $this->getRequest();
121121 $this->load();
122122 # Are we explicity requesting the stable version?
123 - if ( $wgRequest->getIntOrNull( 'stable' ) === 1 ) {
 123+ if ( $request->getIntOrNull( 'stable' ) === 1 ) {
124124 # This only applies to viewing a version of the page...
125 - if ( !$this->isPageView( $wgRequest ) ) {
 125+ if ( !$this->isPageView( $request ) ) {
126126 return false;
127127 # ...with no version parameters other than ?stable=1...
128 - } elseif ( $wgRequest->getVal( 'oldid' ) || $wgRequest->getVal( 'stableid' ) ) {
 128+ } elseif ( $request->getVal( 'oldid' ) || $request->getVal( 'stableid' ) ) {
129129 return false; // over-determined
130130 # ...and the page must be reviewable and have a stable version
131131 } elseif ( !$this->article->getStableRev() ) {
@@ -150,8 +150,9 @@
151151 * @return bool
152152 */
153153 public function useSimpleUI() {
154 - global $wgUser, $wgSimpleFlaggedRevsUI;
155 - return $wgUser->getOption( 'flaggedrevssimpleui', intval( $wgSimpleFlaggedRevsUI ) );
 154+ global $wgSimpleFlaggedRevsUI;
 155+ $reqUser = $this->getUser();
 156+ return $reqUser->getOption( 'flaggedrevssimpleui', intval( $wgSimpleFlaggedRevsUI ) );
156157 }
157158
158159 /**
@@ -245,9 +246,9 @@
246247 * have been reviewed. (e.g. for &oldid=x urls)
247248 */
248249 public function addStableLink() {
249 - global $wgRequest, $wgLang;
 250+ $request = $this->getRequest();
250251 $this->load();
251 - if ( !$this->article->isReviewable() || !$wgRequest->getVal( 'oldid' ) ) {
 252+ if ( !$this->article->isReviewable() || !$request->getVal( 'oldid' ) ) {
252253 return true;
253254 }
254255 # We may have nav links like "direction=prev&oldid=x"
@@ -255,7 +256,7 @@
256257 $frev = FlaggedRevision::newFromTitle( $this->article->getTitle(), $revID );
257258 # Give a notice if this rev ID corresponds to a reviewed version...
258259 if ( $frev ) {
259 - $time = $wgLang->date( $frev->getTimestamp(), true );
 260+ $time = $this->getLang()->date( $frev->getTimestamp(), true );
260261 $flags = $frev->getTags();
261262 $quality = FlaggedRevs::isQuality( $flags );
262263 $msg = $quality ? 'revreview-quality-source' : 'revreview-basic-source';
@@ -278,8 +279,8 @@
279280 * @return mixed int/false/null
280281 */
281282 protected function getRequestedStableId() {
282 - global $wgRequest;
283 - $reqId = $wgRequest->getVal( 'stableid' );
 283+ $request = $this->getRequest();
 284+ $reqId = $request->getVal( 'stableid' );
284285 if ( $reqId === "best" ) {
285286 $reqId = $this->article->getBestFlaggedRevId();
286287 }
@@ -292,10 +293,10 @@
293294 * Adds a quick review form on the bottom if needed
294295 */
295296 public function setPageContent( &$outputDone, &$useParserCache ) {
296 - global $wgRequest;
 297+ $request = $this->getRequest();
297298 $this->load();
298299 # Only trigger on page views with no oldid=x param
299 - if ( !$this->isPageView( $wgRequest ) || $wgRequest->getVal( 'oldid' ) ) {
 300+ if ( !$this->isPageView( $request ) || $request->getVal( 'oldid' ) ) {
300301 return true;
301302 # Only trigger for reviewable pages that exist
302303 } elseif ( !$this->article->exists() || !$this->article->isReviewable() ) {
@@ -391,11 +392,11 @@
392393 * However, any URL with ?stableid=x should not be indexed (as with ?oldid=x).
393394 */
394395 public function setRobotPolicy() {
395 - global $wgRequest;
 396+ $request = $this->getRequest();
396397 if ( $this->article->getStableRev() && $this->article->isStableShownByDefault() ) {
397398 if ( $this->showingStable() ) {
398399 return; // stable version - index this
399 - } elseif ( !$wgRequest->getVal( 'stableid' )
 400+ } elseif ( !$request->getVal( 'stableid' )
400401 && $this->out->getRevisionId() == $this->article->getStable()
401402 && $this->article->stableVersionIsSynced() )
402403 {
@@ -439,13 +440,14 @@
440441 * @return void
441442 */
442443 protected function showDraftVersion( FlaggedRevision $srev, &$tag, $prot ) {
443 - global $wgUser, $wgLang, $wgRequest;
 444+ $request = $this->getRequest();
 445+ $reqUser = $this->getUser();
444446 $this->load();
445447 if ( $this->out->isPrintable() ) {
446448 return; // all this function does is add notices; don't show them
447449 }
448450 $flags = $srev->getTags();
449 - $time = $wgLang->date( $srev->getTimestamp(), true );
 451+ $time = $this->getLang()->date( $srev->getTimestamp(), true );
450452 # Get quality level
451453 $quality = FlaggedRevs::isQuality( $flags );
452454 # Get stable version sync status
@@ -463,10 +465,10 @@
464466 }
465467 # Give a "your edit is pending" notice to newer users if
466468 # an unreviewed edit was completed...
467 - if ( $wgRequest->getVal( 'shownotice' )
468 - && $this->article->getUserText( Revision::RAW ) == $wgUser->getName()
 469+ if ( $request->getVal( 'shownotice' )
 470+ && $this->article->getUserText( Revision::RAW ) == $reqUser->getName()
469471 && $this->article->revsArePending()
470 - && !$wgUser->isAllowed( 'review' ) )
 472+ && !$reqUser->isAllowed( 'review' ) )
471473 {
472474 $revsSince = $this->article->getPendingRevCount();
473475 $pending = $prot;
@@ -475,7 +477,7 @@
476478 }
477479 $pending .= wfMsgExt( 'revreview-edited',
478480 'parseinline', $srev->getRevId(), $revsSince );
479 - $anchor = $wgRequest->getVal( 'fromsection' );
 481+ $anchor = $request->getVal( 'fromsection' );
480482 if ( $anchor != null ) {
481483 $section = str_replace( '_', ' ', $anchor ); // prettify
482484 $pending .= wfMsgExt( 'revreview-edited-section', 'parse', $anchor, $section );
@@ -490,7 +492,7 @@
491493 $revsSince = $this->article->getPendingRevCount();
492494 // Simple icon-based UI
493495 if ( $this->useSimpleUI() ) {
494 - if ( !$wgUser->getId() ) {
 496+ if ( !$reqUser->getId() ) {
495497 $msgHTML = ''; // Anons just see simple icons
496498 } elseif ( $synced ) {
497499 $msg = $quality
@@ -551,10 +553,10 @@
552554 * @return ParserOutput
553555 */
554556 protected function showOldReviewedVersion( FlaggedRevision $frev, &$tag, $prot ) {
555 - global $wgUser, $wgLang;
 557+ $reqUser = $this->getUser();
556558 $this->load();
557559 $flags = $frev->getTags();
558 - $time = $wgLang->date( $frev->getTimestamp(), true );
 560+ $time = $this->getLang()->date( $frev->getTimestamp(), true );
559561 # Set display revision ID
560562 $this->out->setRevisionId( $frev->getRevId() );
561563 # Get quality level
@@ -571,7 +573,7 @@
572574 $icon = FlaggedRevsXML::stableStatusIcon( $quality );
573575 }
574576 $revsSince = $this->article->getPendingRevCount();
575 - if ( !$wgUser->getId() ) {
 577+ if ( !$reqUser->getId() ) {
576578 $msgHTML = ''; // Anons just see simple icons
577579 } else {
578580 $msg = $quality
@@ -602,7 +604,7 @@
603605
604606 $text = $frev->getRevText();
605607 # Get the new stable parser output...
606 - $pOpts = $this->article->makeParserOptions( $wgUser );
 608+ $pOpts = $this->article->makeParserOptions( $reqUser );
607609 $parserOut = FlaggedRevs::parseStableText(
608610 $this->article->getTitle(), $text, $frev->getRevId(), $pOpts );
609611
@@ -629,10 +631,10 @@
630632 * @return ParserOutput
631633 */
632634 protected function showStableVersion( FlaggedRevision $srev, &$tag, $prot ) {
633 - global $wgLang, $wgUser;
 635+ $reqUser = $this->getUser();
634636 $this->load();
635637 $flags = $srev->getTags();
636 - $time = $wgLang->date( $srev->getTimestamp(), true );
 638+ $time = $this->getLang()->date( $srev->getTimestamp(), true );
637639 # Set display revision ID
638640 $this->out->setRevisionId( $srev->getRevId() );
639641 # Get quality level
@@ -649,7 +651,7 @@
650652 if ( $this->showRatingIcon() ) {
651653 $icon = FlaggedRevsXML::stableStatusIcon( $quality );
652654 }
653 - if ( !$wgUser->getId() ) {
 655+ if ( !$reqUser->getId() ) {
654656 $msgHTML = ''; // Anons just see simple icons
655657 } else {
656658 $msg = $quality
@@ -685,7 +687,7 @@
686688 }
687689
688690 # Get parsed stable version and output HTML
689 - $pOpts = $this->article->makeParserOptions( $wgUser );
 691+ $pOpts = $this->article->makeParserOptions( $reqUser );
690692 $parserCache = FRParserCacheStable::singleton();
691693 $parserOut = $parserCache->get( $this->article, $pOpts );
692694
@@ -754,9 +756,9 @@
755757 * @return string, the html line (either "" or "<diff toggle><diff div>")
756758 */
757759 protected function getTopDiffToggle( FlaggedRevision $srev, $quality ) {
758 - global $wgUser;
 760+ $reqUser = $this->getUser();
759761 $this->load();
760 - if ( !$wgUser->getBoolOption( 'flaggedrevsviewdiffs' ) ) {
 762+ if ( !$reqUser->getBoolOption( 'flaggedrevsviewdiffs' ) ) {
761763 return false; // nothing to do here
762764 }
763765 # Diff should only show for the draft
@@ -835,15 +837,15 @@
836838 *
837839 * If no stable version is required, the reference parameters will not be set
838840 *
839 - * Depends on $wgRequest
 841+ * Depends on $request
840842 */
841843 public function imagePageFindFile( &$normalFile, &$displayFile ) {
842 - global $wgRequest;
 844+ $request = $this->getRequest();
843845 $this->load();
844846 # Determine timestamp. A reviewed version may have explicitly been requested...
845847 $frev = null;
846848 $time = false;
847 - $reqId = $wgRequest->getVal( 'stableid' );
 849+ $reqId = $request->getVal( 'stableid' );
848850 if ( $reqId ) {
849851 $frev = FlaggedRevision::newFromTitle( $this->article->getTitle(), $reqId );
850852 } elseif ( $this->showingStable() ) {
@@ -867,7 +869,7 @@
868870 }
869871 if ( !$time ) {
870872 # Try request parameter
871 - $time = $wgRequest->getVal( 'filetimestamp', false );
 873+ $time = $request->getVal( 'filetimestamp', false );
872874 }
873875
874876 if ( !$time ) {
@@ -913,7 +915,8 @@
914916 * Adds stable version tags to page when editing
915917 */
916918 public function addToEditView( EditPage $editPage ) {
917 - global $wgUser, $wgParser;
 919+ global $wgParser;
 920+ $reqUser = $this->getUser();
918921 $this->load();
919922 # Must be reviewable. UI may be limited to unobtrusive patrolling system.
920923 if ( !$this->article->isReviewable() ) {
@@ -932,7 +935,7 @@
933936 $revId = $editPage->oldid ? $editPage->oldid : $latestId;
934937 # Let new users know about review procedure a tag.
935938 # If the log excerpt was shown this is redundant.
936 - if ( !$log && !$wgUser->getId() && $this->article->isStableShownByDefault() ) {
 939+ if ( !$log && !$reqUser->getId() && $this->article->isStableShownByDefault() ) {
937940 $items[] = wfMsgExt( 'revreview-editnotice', 'parseinline' );
938941 }
939942 # Add a notice if there are pending edits...
@@ -943,7 +946,7 @@
944947 # Show diff to stable, to make things less confusing.
945948 # This can be disabled via user preferences and other conditions...
946949 if ( $frev->getRevId() < $latestId // changes were made
947 - && $wgUser->getBoolOption( 'flaggedrevseditdiffs' ) // not disable via prefs
 950+ && $reqUser->getBoolOption( 'flaggedrevseditdiffs' ) // not disable via prefs
948951 && $revId == $latestId // only for current rev
949952 && $editPage->section != 'new' // not for new sections
950953 && $editPage->formtype != 'diff' // not "show changes"
@@ -1030,9 +1033,9 @@
10311034 * Add unreviewed pages links
10321035 */
10331036 public function addToCategoryView() {
1034 - global $wgUser;
 1037+ $reqUser = $this->getUser();
10351038 $this->load();
1036 - if ( !$wgUser->isAllowed( 'review' ) ) {
 1039+ if ( !$reqUser->isAllowed( 'review' ) ) {
10371040 return true;
10381041 }
10391042 if ( !FlaggedRevs::useOnlyIfProtected() ) {
@@ -1056,13 +1059,14 @@
10571060 * @param mixed string|OutputPage
10581061 */
10591062 public function addReviewForm( &$output ) {
1060 - global $wgRequest, $wgUser;
 1063+ $request = $this->getRequest();
 1064+ $reqUser = $this->getUser();
10611065 $this->load();
10621066 if ( $this->out->isPrintable() ) {
10631067 return false; // Must be on non-printable output
10641068 }
10651069 # User must have review rights
1066 - if ( !$wgUser->isAllowed( 'review' ) ) {
 1070+ if ( !$reqUser->isAllowed( 'review' ) ) {
10671071 return true;
10681072 }
10691073 # Page must exist and be reviewable
@@ -1070,7 +1074,7 @@
10711075 return true;
10721076 }
10731077 # Must be a page view action...
1074 - if ( !$this->isPageViewOrDiff( $wgRequest ) ) {
 1078+ if ( !$this->isPageViewOrDiff( $request ) ) {
10751079 return true;
10761080 }
10771081 # Get the revision being displayed
@@ -1082,7 +1086,7 @@
10831087 }
10841088 # Build the review form as needed
10851089 if ( $rev && ( !$this->diffRevs || $this->isReviewableDiff ) ) {
1086 - $form = new RevisionReviewFormUI( $wgUser, $this->article, $rev );
 1090+ $form = new RevisionReviewFormUI( $reqUser, $this->article, $rev );
10871091 # Default tags and existence of "reject" button depend on context
10881092 if ( $this->diffRevs ) {
10891093 $form->setDiffPriorRev( $this->diffRevs['old'] );
@@ -1107,7 +1111,7 @@
11081112 # $wgOut may not already have the inclusion IDs, such as for diffonly=1.
11091113 # RevisionReviewForm will fetch them as needed however.
11101114 list( $tmpVers, $fileVers ) =
1111 - FRInclusionCache::getRevIncludes( $this->article, $rev, $wgUser );
 1115+ FRInclusionCache::getRevIncludes( $this->article, $rev, $reqUser );
11121116 }
11131117 $form->setIncludeVersions( $tmpVers, $fileVers );
11141118
@@ -1127,7 +1131,7 @@
11281132 * Add link to stable version setting to protection form
11291133 */
11301134 public function addStabilizationLink() {
1131 - global $wgRequest;
 1135+ $request = $this->getRequest();
11321136 $this->load();
11331137 if ( FlaggedRevs::useProtectionLevels() ) {
11341138 return true; // simple custom levels set for action=protect
@@ -1136,7 +1140,7 @@
11371141 if ( !FlaggedRevs::inReviewNamespace( $this->article->getTitle() ) ) {
11381142 return true;
11391143 }
1140 - $action = $wgRequest->getVal( 'action', 'view' );
 1144+ $action = $request->getVal( 'action', 'view' );
11411145 if ( $action == 'protect' || $action == 'unprotect' ) {
11421146 $title = SpecialPage::getTitleFor( 'Stabilization' );
11431147 # Give a link to the page to configure the stable version
@@ -1163,7 +1167,7 @@
11641168 * SkinTemplateTabs, to inlude flagged revs UI elements
11651169 */
11661170 public function setActionTabs( $skin, array &$actions ) {
1167 - global $wgUser;
 1171+ $reqUser = $this->getUser();
11681172 $this->load();
11691173 if ( FlaggedRevs::useProtectionLevels() ) {
11701174 return true; // simple custom levels set for action=protect
@@ -1178,7 +1182,7 @@
11791183 is_array( $actions ) &&
11801184 !isset( $actions['protect'] ) &&
11811185 !isset( $actions['unprotect'] ) &&
1182 - $wgUser->isAllowed( 'stablesettings' ) &&
 1186+ $reqUser->isAllowed( 'stablesettings' ) &&
11831187 $title->exists() )
11841188 {
11851189 $stableTitle = SpecialPage::getTitleFor( 'Stabilization' );
@@ -1231,7 +1235,7 @@
12321236
12331237 // Add "pending changes" tab and set tab selection CSS
12341238 protected function addDraftTab( array &$views, FlaggedRevision $srev, $type ) {
1235 - global $wgRequest;
 1239+ $request = $this->getRequest();
12361240 $title = $this->article->getTitle(); // convenience
12371241 $tabs = array(
12381242 'read' => array( // view stable
@@ -1246,10 +1250,10 @@
12471251 ),
12481252 );
12491253 // Set tab selection CSS
1250 - if ( $this->showingStable() || $wgRequest->getVal( 'stableid' ) ) {
 1254+ if ( $this->showingStable() || $request->getVal( 'stableid' ) ) {
12511255 // We are looking a the stable version or an old reviewed one
12521256 $tabs['read']['class'] = 'selected';
1253 - } elseif ( $this->isPageViewOrDiff( $wgRequest ) ) {
 1257+ } elseif ( $this->isPageViewOrDiff( $request ) ) {
12541258 $ts = null;
12551259 if ( $this->out->getRevisionId() ) { // @TODO: avoid same query in Skin.php
12561260 $ts = ( $this->out->getRevisionId() == $this->article->getLatest() )
@@ -1316,12 +1320,12 @@
13171321 * @return bool
13181322 */
13191323 protected function pageWriteOpRequested() {
1320 - global $wgRequest;
 1324+ $request = $this->getRequest();
13211325 # Hack for bug 16734 (some actions update and view all at once)
1322 - $action = $wgRequest->getVal( 'action' );
 1326+ $action = $request->getVal( 'action' );
13231327 if ( $action === 'rollback' ) {
13241328 return true;
1325 - } elseif ( $action === 'delete' && $wgRequest->wasPosted() ) {
 1329+ } elseif ( $action === 'delete' && $request->wasPosted() ) {
13261330 return true;
13271331 }
13281332 return false;
@@ -1339,9 +1343,8 @@
13401344 * @return void
13411345 */
13421346 public function setPendingNotice( FlaggedRevision $srev, $diffToggle = '' ) {
1343 - global $wgLang;
13441347 $this->load();
1345 - $time = $wgLang->date( $srev->getTimestamp(), true );
 1348+ $time = $this->getLang()->date( $srev->getTimestamp(), true );
13461349 $revsSince = $this->article->getPendingRevCount();
13471350 $msg = $srev->getQuality()
13481351 ? 'revreview-newest-quality'
@@ -1363,7 +1366,9 @@
13641367 * (ii) List any template/file changes pending review
13651368 */
13661369 public function addToDiffView( $diff, $oldRev, $newRev ) {
1367 - global $wgRequest, $wgUser, $wgMemc, $wgParserCacheExpireTime;
 1370+ global $wgMemc, $wgParserCacheExpireTime;
 1371+ $request = $this->getRequest();
 1372+ $reqUser = $this->getUser();
13681373 $this->load();
13691374 # Exempt printer-friendly output
13701375 if ( $this->out->isPrintable() ) {
@@ -1400,7 +1405,7 @@
14011406 }
14021407 # Otherwise, check for includes pending on top of edits pending...
14031408 } else {
1404 - $incs = FRInclusionCache::getRevIncludes( $this->article, $newRev, $wgUser );
 1409+ $incs = FRInclusionCache::getRevIncludes( $this->article, $newRev, $reqUser );
14051410 $this->oldRevIncludes = $incs; // process cache
14061411 # Add a list of links to each changed template...
14071412 $changeList = self::fetchTemplateChanges( $srev, $incs[0] );
@@ -1410,11 +1415,11 @@
14111416 # If there are pending revs or templates/files changes, notify the user...
14121417 if ( $this->article->revsArePending() || count( $changeList ) ) {
14131418 # If the user can review then prompt them to review them...
1414 - if ( $wgUser->isAllowed( 'review' ) ) {
 1419+ if ( $reqUser->isAllowed( 'review' ) ) {
14151420 // Reviewer just edited...
1416 - if ( $wgRequest->getInt( 'shownotice' )
 1421+ if ( $request->getInt( 'shownotice' )
14171422 && $newRev->isCurrent()
1418 - && $newRev->getRawUserText() == $wgUser->getName() )
 1423+ && $newRev->getRawUserText() == $reqUser->getName() )
14191424 {
14201425 $title = $this->article->getTitle(); // convenience
14211426 // @TODO: make diff class cache this
@@ -1439,7 +1444,7 @@
14401445 }
14411446 # template/file change list
14421447 if ( $changeText != '' ) {
1443 - if ( $wgUser->isAllowed( 'review' ) ) {
 1448+ if ( $reqUser->isAllowed( 'review' ) ) {
14441449 $this->diffIncChangeBox = "<p>$changeText</p>";
14451450 } else {
14461451 $css = 'flaggedrevs_diffnotice plainlinks';
@@ -1498,7 +1503,7 @@
14991504 protected static function diffToStableLink(
15001505 FlaggedPage $article, $oldRev, Revision $newRev
15011506 ) {
1502 - global $wgUser;
 1507+ $reqUser = $this->getUser();
15031508 $srev = $article->getStableRev();
15041509 if ( !$srev ) {
15051510 return ''; // nothing to do
@@ -1510,7 +1515,7 @@
15111516 # Make a link to the full diff-to-stable if:
15121517 # (a) Actual revs are pending and (b) We are not viewing the full diff-to-stable
15131518 if ( $article->revsArePending() && !$fullStableDiff ) {
1514 - $review = $wgUser->getSkin()->linkKnown(
 1519+ $review = $reqUser->getSkin()->linkKnown(
15151520 $article->getTitle(),
15161521 wfMsgHtml( 'review-diff2stable' ),
15171522 array(),
@@ -1573,8 +1578,8 @@
15741579 // Fetch template changes for a reviewed revision since review
15751580 // @return array
15761581 protected static function fetchTemplateChanges( FlaggedRevision $frev, $newTemplates = null ) {
1577 - global $wgUser;
1578 - $skin = $wgUser->getSkin();
 1582+ $reqUser = $this->getUser();
 1583+ $skin = $reqUser->getSkin();
15791584 $diffLinks = array();
15801585 if ( $newTemplates === null ) {
15811586 $changes = $frev->findPendingTemplateChanges();
@@ -1599,8 +1604,8 @@
16001605 // Fetch file changes for a reviewed revision since review
16011606 // @return array
16021607 protected static function fetchFileChanges( FlaggedRevision $frev, $newFiles = null ) {
1603 - global $wgUser;
1604 - $skin = $wgUser->getSkin();
 1608+ $reqUser = $this->getUser();
 1609+ $skin = $reqUser->getSkin();
16051610 $diffLinks = array();
16061611 if ( $newFiles === null ) {
16071612 $changes = $frev->findPendingFileChanges( 'noForeign' );
@@ -1664,7 +1669,7 @@
16651670 * Only for people who can review and for pages that have a stable version.
16661671 */
16671672 public function injectPostEditURLParams( &$sectionAnchor, &$extraQuery ) {
1668 - global $wgUser;
 1673+ $reqUser = $this->getUser();
16691674 $this->load();
16701675 $this->article->loadPageData( 'fromdbmaster' );
16711676 # Get the stable version from the master
@@ -1675,7 +1680,7 @@
16761681 $params = array();
16771682 // If the edit was not autoreviewed, and the user can actually make a
16781683 // new stable version, then go to the diff...
1679 - if ( $frev->userCanSetFlags( $wgUser ) ) {
 1684+ if ( $frev->userCanSetFlags( $reqUser ) ) {
16801685 $params += array( 'oldid' => $frev->getRevId(), 'diff' => 'cur', 'shownotice' => 1 );
16811686 $params += FlaggedRevs::diffOnlyCGI();
16821687 // ...otherwise, go to the draft revision after completing an edit.
@@ -1683,7 +1688,7 @@
16841689 } else {
16851690 $params += array( 'stable' => 0 );
16861691 // Show a notice at the top of the page for non-reviewers...
1687 - if ( !$wgUser->isAllowed( 'review' ) && $this->article->isStableShownByDefault() ) {
 1692+ if ( !$reqUser->isAllowed( 'review' ) && $this->article->isStableShownByDefault() ) {
16881693 $params += array( 'shownotice' => 1 );
16891694 if ( $sectionAnchor ) {
16901695 // Pass a section parameter in the URL as needed to add a link to
@@ -1737,11 +1742,11 @@
17381743 * @return bool
17391744 */
17401745 protected function editWillRequireReview( EditPage $editPage ) {
1741 - global $wgRequest;
 1746+ $request = $this->getRequest();
17421747 $title = $this->article->getTitle(); // convenience
17431748 if ( !$this->editRequiresReview( $editPage ) ) {
17441749 return false; // edit will go live immediatly
1745 - } elseif ( $wgRequest->getCheck( 'wpReviewEdit' ) && $title->userCan( 'review' ) ) {
 1750+ } elseif ( $request->getCheck( 'wpReviewEdit' ) && $title->userCan( 'review' ) ) {
17461751 return false; // edit checked off to be reviewed on save
17471752 }
17481753 return true; // edit needs review
@@ -1793,7 +1798,7 @@
17941799 * (b) this is an unreviewed page (bug 23970)
17951800 */
17961801 public function addReviewCheck( EditPage $editPage, array &$checkboxes, &$tabindex ) {
1797 - global $wgRequest;
 1802+ $request = $this->getRequest();
17981803 $title = $this->article->getTitle(); // convenience
17991804 if ( !$this->article->isReviewable() || !$title->userCan( 'review' ) ) {
18001805 return true; // not needed
@@ -1807,7 +1812,7 @@
18081813 # Note: check not shown when editing old revisions, which is confusing.
18091814 $checkbox = Xml::check(
18101815 'wpReviewEdit',
1811 - $wgRequest->getCheck( 'wpReviewEdit' ),
 1816+ $request->getCheck( 'wpReviewEdit' ),
18121817 array( 'tabindex' => ++$tabindex, 'id' => 'wpReviewEdit' )
18131818 );
18141819 $attribs = array( 'for' => 'wpReviewEdit' );
@@ -1856,17 +1861,17 @@
18571862 * @return int
18581863 */
18591864 protected static function getBaseRevId( EditPage $editPage ) {
1860 - global $wgRequest;
 1865+ $request = $this->getRequest();
18611866 if ( !isset( $editPage->fr_baseRevId ) ) {
18621867 $article = $editPage->getArticle(); // convenience
18631868 $latestId = $article->getLatest(); // current rev
1864 - $undo = $wgRequest->getIntOrNull( 'undo' );
 1869+ $undo = $request->getIntOrNull( 'undo' );
18651870 # Undoing consecutive top edits...
18661871 if ( $undo && $undo === $latestId ) {
18671872 # Treat this like a revert to a base revision.
18681873 # We are undoing all edits *after* some rev ID (undoafter).
18691874 # If undoafter is not given, then it is the previous rev ID.
1870 - $revId = $wgRequest->getInt( 'undoafter',
 1875+ $revId = $request->getInt( 'undoafter',
18711876 $article->getTitle()->getPreviousRevisionID( $latestId, Title::GAID_FOR_UPDATE ) );
18721877 # Undoing other edits...
18731878 } elseif ( $undo ) {
@@ -1877,7 +1882,7 @@
18781883 # Otherwise, check if the client specified the ID (bug 23098).
18791884 $revId = $article->getOldID()
18801885 ? $article->getOldID()
1881 - : $wgRequest->getInt( 'baseRevId' ); // e.g. "show changes"/"preview"
 1886+ : $request->getInt( 'baseRevId' ); // e.g. "show changes"/"preview"
18821887 }
18831888 # Zero oldid => draft revision
18841889 if ( !$revId ) {

Follow-up revisions

RevisionCommit summaryAuthorDate
r99051Fixed fatals in r99047 by just using Linker classaaron20:41, 5 October 2011
r99052Fixed use of $this in static function from r99047aaron21:07, 5 October 2011

Status & tagging log