r81810 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r81809‎ | r81810 | r81811 >
Date:08:52, 9 February 2011
Author:aaron
Status:deferred
Tags:
Comment:
* Rewrote pageOverride() function into different functions, showingStable() this most important.
* Renamed getVisibilitySettings -> getStabilitySettings & getPageVisibilitySettings -> getPageStabilitySettings.
* Renamed showDraftByDefault -> userViewsDraftByDefault and added sanity check.
* Removed isDiffShownOnEdit(), which presumes crap about how the user got to the edit form.
* Fixes and clean-up for overrideRedirect()
* Added short-circuit to getStableRev() and fixed negative caching.
* Removed some redundant isReviewable() checks.
* Made FlaggedArticle::isStableShownByDefault() more intuitive.
* Removed useless $simpleTag var
* Various comment tweaks
Modified paths:
  • /trunk/extensions/FlaggedRevs/FlaggedArticle.php (modified) (history)
  • /trunk/extensions/FlaggedRevs/FlaggedArticleView.php (modified) (history)
  • /trunk/extensions/FlaggedRevs/FlaggedRevision.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/forms/PageStabilityForm.php (modified) (history)

Diff [purge]

Index: trunk/extensions/FlaggedRevs/FlaggedRevs.php
@@ -82,7 +82,7 @@
8383 # Below are groups that see the current revision by default.
8484 # This makes editing easier since the users always start off
8585 # viewing the latest version of pages.
86 -$wgFlaggedRevsExceptions = array( 'user' );
 86+$wgFlaggedRevsExceptions = array( 'user' ); // @TODO: remove when ready (and swap pref)
8787
8888 # Can users make comments that will show up below flagged revisions?
8989 # NOTE: this is NOT the same as the simple log comment
Index: trunk/extensions/FlaggedRevs/FlaggedArticle.php
@@ -81,8 +81,10 @@
8282 * @return bool
8383 */
8484 public function isStableShownByDefault( $flags = 0 ) {
85 - # Get page configuration
86 - $config = $this->getVisibilitySettings( $flags );
 85+ if ( !$this->isReviewable( $flags ) ) {
 86+ return false; // no stable versions can exist
 87+ }
 88+ $config = $this->getStabilitySettings( $flags ); // page configuration
8789 return (bool)$config['override'];
8890 }
8991
@@ -239,7 +241,7 @@
240242 }
241243
242244 /**
243 - * Should tags only be shown for unreviewed content for this user?
 245+ * Tags are only shown for unreviewed content and this page is not locked/unlocked?
244246 * @return bool
245247 */
246248 public function lowProfileUI() {
@@ -256,8 +258,12 @@
257259 if ( !FlaggedRevs::inReviewNamespace( $this->getTitle() ) ) {
258260 return false;
259261 }
260 - return !( FlaggedRevs::useOnlyIfProtected()
261 - && !$this->isStableShownByDefault( $flags ) );
 262+ # Check if flagging is disabled for this page via config
 263+ if ( FlaggedRevs::useOnlyIfProtected() ) {
 264+ $config = $this->getStabilitySettings( $flags ); // page configuration
 265+ return (bool)$config['override']; // stable is default or flagging disabled
 266+ }
 267+ return true;
262268 }
263269
264270 /**
@@ -279,8 +285,11 @@
280286 */
281287 public function getStableRev( $flags = 0 ) {
282288 # Cached results available?
283 - if ( $this->stableRev == null || ( $flags & FR_MASTER ) ) {
284 - $srev = FlaggedRevision::newFromStable( $this->getTitle(), $flags );
 289+ if ( $this->stableRev === null || ( $flags & FR_MASTER ) ) {
 290+ $srev = null;
 291+ if ( $this->isReviewable( $flags ) ) { // short-circuit if not reviewable
 292+ $srev = FlaggedRevision::newFromStable( $this->getTitle(), $flags );
 293+ }
285294 $this->stableRev = $srev ? $srev : false; // false => "found nothing"
286295 }
287296 if ( $this->stableRev ) {
@@ -304,13 +313,11 @@
305314 * @param int $flags, FR_MASTER
306315 * @return array (select,override)
307316 */
308 - public function getVisibilitySettings( $flags = 0 ) {
309 - # Cached results available?
 317+ public function getStabilitySettings( $flags = 0 ) {
310318 if ( !( $flags & FR_MASTER ) && $this->pageConfig !== null ) {
311 - return $this->pageConfig;
 319+ return $this->pageConfig; // use process cache
312320 }
313 - $config = FlaggedRevs::getPageVisibilitySettings( $this->getTitle(), $flags );
314 - $this->pageConfig = $config;
315 - return $config;
 321+ $this->pageConfig = FlaggedRevs::getPageStabilitySettings( $this->getTitle(), $flags );
 322+ return $this->pageConfig;
316323 }
317324 }
Index: trunk/extensions/FlaggedRevs/FlaggedRevs.class.php
@@ -959,7 +959,7 @@
960960 * @param int $flags, FR_MASTER
961961 * @returns array (associative) (select,override,autoreview,expiry)
962962 */
963 - public static function getPageVisibilitySettings( Title $title, $flags = 0 ) {
 963+ public static function getPageStabilitySettings( Title $title, $flags = 0 ) {
964964 $db = ( $flags & FR_MASTER ) ?
965965 wfGetDB( DB_MASTER ) : wfGetDB( DB_SLAVE );
966966 $row = $db->selectRow( 'flaggedpage_config',
Index: trunk/extensions/FlaggedRevs/forms/PageStabilityForm.php
@@ -183,7 +183,7 @@
184184
185185 protected function loadOldConfig() {
186186 # Get the current page config and GMT expiry
187 - $this->oldConfig = FlaggedRevs::getPageVisibilitySettings( $this->page, FR_MASTER );
 187+ $this->oldConfig = FlaggedRevs::getPageStabilitySettings( $this->page, FR_MASTER );
188188 $this->oldExpiry = $this->oldConfig['expiry'] === 'infinity'
189189 ? 'infinite'
190190 : wfTimestamp( TS_RFC2822, $this->oldConfig['expiry'] );
@@ -637,4 +637,4 @@
638638 || $oldRow->fpc_expiry != $dbExpiry // ...expiry changed
639639 );
640640 }
641 -}
\ No newline at end of file
 641+}
Index: trunk/extensions/FlaggedRevs/FlaggedRevision.php
@@ -194,7 +194,7 @@
195195 }
196196 # Get visiblity settings...
197197 if ( empty( $config ) ) {
198 - $config = FlaggedRevs::getPageVisibilitySettings( $title, $flags );
 198+ $config = FlaggedRevs::getPageStabilitySettings( $title, $flags );
199199 }
200200 if ( !$config['override'] && FlaggedRevs::useOnlyIfProtected() ) {
201201 return null; // page is not reviewable; no stable version
Index: trunk/extensions/FlaggedRevs/FlaggedRevs.hooks.php
@@ -539,7 +539,7 @@
540540 if( !FlaggedRevs::inReviewNamespace( $title ) ) {
541541 $ret = '';
542542 } else {
543 - $config = FlaggedRevs::getPageVisibilitySettings( $title );
 543+ $config = FlaggedRevs::getPageStabilitySettings( $title );
544544 $ret = $config['autoreview'];
545545 }
546546 }
@@ -593,10 +593,10 @@
594594 # Don't let users vandalize pages by moving them...
595595 if ( $action === 'move' ) {
596596 if ( !FlaggedRevs::inReviewNamespace( $title ) || !$title->exists() ) {
597 - return true;
 597+ return true; // extra short-circuit
598598 }
599599 $flaggedArticle = FlaggedArticle::getTitleInstance( $title );
600 - # If the current shows be default anyway, nothing to do...
 600+ # If the draft shows by default anyway, nothing to do...
601601 if ( !$flaggedArticle->isStableShownByDefault() ) {
602602 return true;
603603 }
@@ -621,7 +621,7 @@
622622 } else if ( $action === 'autoreview' || $action === 'review' ) {
623623 # Get autoreview restriction settings...
624624 $fa = FlaggedArticle::getTitleInstance( $title );
625 - $config = $fa->getVisibilitySettings();
 625+ $config = $fa->getStabilitySettings();
626626 # Convert Sysop -> protect
627627 $right = ( $config['autoreview'] === 'sysop' ) ?
628628 'protect' : $config['autoreview'];
@@ -1390,33 +1390,40 @@
13911391 if ( !$fa->isReviewable() ) {
13921392 return true; // nothing to do
13931393 }
 1394+ # Viewing an old reviewed version...
13941395 if ( $request->getVal( 'stableid' ) ) {
1395 - $ignoreRedirect = true;
1396 - } else {
1397 - # Try the cache...
 1396+ $ignoreRedirect = true; // don't redirect (same as ?oldid=x)
 1397+ return true;
 1398+ }
 1399+ $srev = $fa->getStableRev();
 1400+ $view = FlaggedArticleView::singleton();
 1401+ # Check if we are viewing an unsynced stable version...
 1402+ if ( $srev && $view->showingStable() && $srev->getRevId() != $article->getLatest() ) {
 1403+ # Check the stable redirect properties from the cache...
13981404 $key = wfMemcKey( 'flaggedrevs', 'overrideRedirect', $article->getId() );
13991405 $tuple = FlaggedRevs::getMemcValue( $wgMemc->get( $key ), $article );
1400 - if ( is_array( $tuple ) ) {
 1406+ if ( is_array( $tuple ) ) { // cache hit
14011407 list( $ignoreRedirect, $target ) = $tuple;
1402 - return true; // use stable redirect
1403 - }
1404 - $srev = $fa->getStableRev();
1405 - if ( $srev ) {
1406 - $view = FlaggedArticleView::singleton();
1407 - # If synced, nothing special here...
1408 - if ( $srev->getRevId() != $article->getLatest() && $view->pageOverride() ) {
1409 - $text = $srev->getRevText();
1410 - $redirect = $fa->followRedirectText( $text );
1411 - if ( $redirect ) {
1412 - $target = $redirect; // use stable redirect
1413 - } else {
1414 - $ignoreRedirect = true;
1415 - }
 1408+ } else { // cache miss; fetch the stable rev text...
 1409+ $text = $srev->getRevText();
 1410+ $redirect = $fa->getRedirectURL( Title::newFromRedirectRecurse( $text ) );
 1411+ if ( $redirect ) {
 1412+ $target = $redirect; // use stable redirect
 1413+ } else {
 1414+ $ignoreRedirect = true; // make MW skip redirection
14161415 }
14171416 $data = FlaggedRevs::makeMemcObj( array( $ignoreRedirect, $target ) );
1418 - $wgMemc->set( $key, $data, $wgParserCacheExpireTime );
 1417+ $wgMemc->set( $key, $data, $wgParserCacheExpireTime ); // cache results
14191418 }
 1419+ $clearEnvironment = (bool)$target;
 1420+ # Check if the we are viewing a draft or synced stable version...
 1421+ } else {
 1422+ # In both cases, we can just let MW use followRedirect()
 1423+ # on the draft as normal, avoiding any page text hits.
 1424+ $clearEnvironment = $article->isRedirect();
14201425 }
 1426+ # Environment (e.g. $wgTitle) will change in MediaWiki::initializeArticle
 1427+ if ( $clearEnvironment ) $view->clear();
14211428 return true;
14221429 }
14231430
@@ -1824,7 +1831,7 @@
18251832 array() : array( 'disabled' => 'disabled' );
18261833
18271834 # Get the current config/expiry
1828 - $config = FlaggedRevs::getPageVisibilitySettings( $article->getTitle(), FR_MASTER );
 1835+ $config = FlaggedRevs::getPageStabilitySettings( $article->getTitle(), FR_MASTER );
18291836 $oldExpirySelect = ( $config['expiry'] == 'infinity' ) ? 'infinite' : 'existing';
18301837
18311838 # Load requested restriction level, default to current level...
Index: trunk/extensions/FlaggedRevs/FlaggedArticleView.php
@@ -31,6 +31,14 @@
3232 protected function __clone() { }
3333
3434 /*
 35+ * Clear the FlaggedArticleView for this request.
 36+ * Only needed when page redirection changes the environment.
 37+ */
 38+ public function clear() {
 39+ self::$instance = null;
 40+ }
 41+
 42+ /*
3543 * Load the global FlaggedArticle instance
3644 */
3745 protected function load() {
@@ -56,47 +64,71 @@
5765 }
5866
5967 /**
60 - * Do the config and current URL params allow
61 - * for content overriding by the stable version?
 68+ * Is this web response for a request to view a page where both:
 69+ * (a) no specific page version was requested via URL params
 70+ * (b) a stable version exists and is to be displayed
 71+ * This factors in site/page config, user preferences, and web request params.
6272 * @returns bool
6373 */
64 - public function pageOverride() {
 74+ protected function showingStableAsDefault() {
6575 global $wgUser, $wgRequest;
6676 $this->load();
67 - # This only applies to viewing content pages
68 - $action = $wgRequest->getVal( 'action', 'view' );
69 - if ( !self::isViewAction( $action ) || !$this->article->isReviewable() ) {
 77+ # This only applies to viewing the default version of pages...
 78+ if ( !$this->isDefaultPageView( $wgRequest ) ) {
7079 return false;
71 - }
72 - # Does not apply to diffs/old revision...
73 - if ( $wgRequest->getVal( 'oldid' ) || $wgRequest->getVal( 'diff' ) ) {
 80+ # ...and the page must be reviewable and have a stable version
 81+ } elseif ( !$this->article->getStableRev() ) {
7482 return false;
7583 }
76 - # Explicit requests for a certain stable version handled elsewhere...
77 - if ( $wgRequest->getVal( 'stableid' ) ) {
 84+ # Check user preferences ("show stable by default?")
 85+ if ( $wgUser->getOption( 'flaggedrevsstable' ) ) {
 86+ return true;
 87+ }
 88+ # Viewer may be in a group that sees the draft by default
 89+ if ( $this->userViewsDraftByDefault( $wgUser ) ) {
7890 return false;
7991 }
80 - # Check user preferences
81 - if ( $wgUser->getOption( 'flaggedrevsstable' ) ) {
82 - return !( $wgRequest->getIntOrNull( 'stable' ) === 0 );
83 - }
84 - # Get page configuration
85 - $config = $this->article->getVisibilitySettings();
86 - # Does the stable version override the current one?
87 - if ( $config['override'] ) {
88 - if ( $this->showDraftByDefault() ) {
89 - return ( $wgRequest->getIntOrNull( 'stable' ) === 1 );
 92+ # Does the stable version override the draft?
 93+ $config = $this->article->getStabilitySettings();
 94+ return (bool)$config['override'];
 95+ }
 96+
 97+ /**
 98+ * Is this web response for a request to view a page where both:
 99+ * (a) the stable version of a page was requested (?stable=1)
 100+ * (b) the stable version exists and is to be displayed
 101+ * @returns bool
 102+ */
 103+ protected function showingStableByRequest() {
 104+ global $wgRequest;
 105+ $this->load();
 106+ # Are we explicity requesting the stable version?
 107+ if ( $wgRequest->getIntOrNull( 'stable' ) === 1 ) {
 108+ # This only applies to viewing a version of the page...
 109+ if ( !$this->isPageView( $wgRequest ) ) {
 110+ return false;
 111+ # ...with no version parameters other than ?stable=1...
 112+ } elseif ( $wgRequest->getVal( 'oldid' ) || $wgRequest->getVal( 'stableid' ) ) {
 113+ return false; // over-determined
 114+ # ...and the page must be reviewable and have a stable version
 115+ } elseif ( !$this->article->getStableRev() ) {
 116+ return false;
90117 }
91 - # Viewer sees stable by default
92 - return !( $wgRequest->getIntOrNull( 'stable' ) === 0 );
93 - # We are explicity requesting the stable version?
94 - } elseif ( $wgRequest->getIntOrNull( 'stable' ) === 1 ) {
95 - return true;
 118+ return true; // show stable version
96119 }
97120 return false;
98121 }
99122
100123 /**
 124+ * Is this web response for a request to view a page
 125+ * where a stable version exists and is to be displayed
 126+ * @returns bool
 127+ */
 128+ public function showingStable() {
 129+ return $this->showingStableByRequest() || $this->showingStableAsDefault();
 130+ }
 131+
 132+ /**
101133 * Should this be using a simple icon-based UI?
102134 * Check the user's preferences first, using the site settings as the default.
103135 * @returns bool
@@ -107,19 +139,23 @@
108140 }
109141
110142 /**
111 - * Should this user see the current revision by default?
112 - * Note: intended for users that probably edit
 143+ * Should this user see the draft revision of pages by default?
 144+ * @param $user User
113145 * @returns bool
114146 */
115 - public function showDraftByDefault() {
116 - global $wgFlaggedRevsExceptions, $wgUser;
 147+ protected function userViewsDraftByDefault( $user ) {
 148+ global $wgFlaggedRevsExceptions;
 149+ # Check user preferences ("show stable by default?")
 150+ if ( $user->getOption( 'flaggedrevsstable' ) ) {
 151+ return false;
 152+ }
117153 # Viewer sees current by default (editors, insiders, ect...) ?
118154 foreach ( $wgFlaggedRevsExceptions as $group ) {
119155 if ( $group == 'user' ) {
120 - if ( $wgUser->getId() ) {
 156+ if ( $user->getId() ) {
121157 return true;
122158 }
123 - } elseif ( in_array( $group, $wgUser->getGroups() ) ) {
 159+ } elseif ( in_array( $group, $user->getGroups() ) ) {
124160 return true;
125161 }
126162 }
@@ -127,36 +163,51 @@
128164 }
129165
130166 /**
131 - * Is this user shown the stable version by default for this page?
 167+ * Is this a view page action (including diffs)?
 168+ * @param $request WebRequest
132169 * @returns bool
133170 */
134 - public function isStableShownByDefaultUser() {
135 - $this->load();
136 - if ( $this->article->isReviewable() ) {
137 - $config = $this->article->getVisibilitySettings(); // page configuration
138 - return ( $config['override'] && !$this->showDraftByDefault() );
139 - }
140 - return false; // no stable
 171+ protected function isPageViewOrDiff( WebRequest $request ) {
 172+ global $mediaWiki;
 173+ $action = isset( $mediaWiki )
 174+ ? $mediaWiki->getAction( $request )
 175+ : $request->getVal( 'action', 'view' ); // cli
 176+ return self::isViewAction( $action );
141177 }
142 -
 178+
143179 /**
144 - * Is this user shown the diff-to-stable on edit for this page?
 180+ * Is this a view page action (not including diffs)?
 181+ * @param $request WebRequest
145182 * @returns bool
146183 */
147 - public function isDiffShownOnEdit() {
148 - global $wgUser;
149 - $this->load();
150 - return ( $wgUser->isAllowed( 'review' ) || $this->isStableShownByDefaultUser() );
 184+ protected function isPageView( WebRequest $request ) {
 185+ return $this->isPageViewOrDiff( $request ) && !$request->getVal( 'diff' );
151186 }
152187
153188 /**
 189+ * Is this a web request to just *view* the *default* version of a page?
 190+ * @param $request WebRequest
 191+ * @returns bool
 192+ */
 193+ protected function isDefaultPageView( WebRequest $request ) {
 194+ global $mediaWiki;
 195+ $action = isset( $mediaWiki )
 196+ ? $mediaWiki->getAction( $request )
 197+ : $request->getVal( 'action', 'view' ); // cli
 198+ return ( self::isViewAction( $action )
 199+ && !$request->getVal( 'oldid' )
 200+ && !$request->getVal( 'stable' )
 201+ && !$request->getVal( 'stableid' )
 202+ && !$request->getVal( 'diff' ) );
 203+ }
 204+
 205+ /**
154206 * Is this a view page action?
155 - * @param $action string
 207+ * @param $action string from MediaWiki::getAction()
156208 * @returns bool
157209 */
158210 protected static function isViewAction( $action ) {
159 - return ( $action == 'view' || $action == 'purge' || $action == 'render'
160 - || $action == 'historysubmit' );
 211+ return ( $action == 'view' || $action == 'purge' || $action == 'render' );
161212 }
162213
163214 /**
@@ -226,25 +277,20 @@
227278 public function setPageContent( &$outputDone, &$useParserCache ) {
228279 global $wgRequest, $wgOut, $wgContLang;
229280 $this->load();
230 - # Only trigger on article view for content pages, not for protect/delete/hist...
231 - $action = $wgRequest->getVal( 'action', 'view' );
232 - if ( !self::isViewAction( $action ) || !$this->article->exists() )
 281+ # Only trigger on page views with no oldid=x param
 282+ if ( !$this->isPageView( $wgRequest ) || $wgRequest->getVal( 'oldid' ) ) {
233283 return true;
234 - # Do not clutter up diffs any further and leave archived versions alone...
235 - if ( $wgRequest->getVal( 'diff' ) || $wgRequest->getVal( 'oldid' ) ) {
 284+ # Only trigger for reviewable pages that exist
 285+ } elseif ( !$this->article->exists() || !$this->article->isReviewable() ) {
236286 return true;
237287 }
238 - # Only trigger for reviewable pages
239 - if ( !$this->article->isReviewable() ) {
240 - return true;
241 - }
242 - $simpleTag = $old = $stable = false;
243288 $tag = '';
 289+ $old = $stable = false;
244290 # Check the newest stable version.
245291 $srev = $this->article->getStableRev();
246292 $stableId = $srev ? $srev->getRevId() : 0;
247293 $frev = $srev; // $frev is the revision we are looking at
248 - # Check for any explicitly requested old stable version...
 294+ # Check for any explicitly requested reviewed version (stableid=X)...
249295 $reqId = $this->getRequestedStableId();
250296 if ( $reqId ) {
251297 if ( !$stableId ) {
@@ -252,8 +298,8 @@
253299 # Treat requesting the stable version by ID as &stable=1
254300 } else if ( $reqId != $stableId ) {
255301 $old = true; // old reviewed version requested by ID
256 - $frev = FlaggedRevision::newFromTitle( $this->article->getTitle(),
257 - $reqId, FR_TEXT );
 302+ $frev = FlaggedRevision::newFromTitle(
 303+ $this->article->getTitle(), $reqId, FR_TEXT );
258304 if ( !$frev ) {
259305 $reqId = false; // invalid ID given
260306 }
@@ -292,8 +338,8 @@
293339 $outputDone = true; # Tell MW that parser output is done
294340 $useParserCache = false;
295341 // Stable version requested by ID or relevant conditions met to
296 - // to override page view.
297 - } else if ( $stable || $this->pageOverride() ) {
 342+ // to override page view with the stable version.
 343+ } else if ( $stable || $this->showingStable() ) {
298344 $this->showStableVersion( $srev, $tag, $prot );
299345 $outputDone = true; # Tell MW that parser output is done
300346 $useParserCache = false;
@@ -309,8 +355,6 @@
310356 $tagClass = 'flaggedrevs_short';
311357 # Collapse the box details on mouseOut
312358 $encJS .= ' onmouseout="FlaggedRevs.onBoxMouseOut(event)"';
313 - } elseif ( $simpleTag ) {
314 - $tagClass = 'flaggedrevs_notice';
315359 } elseif ( $pristine ) {
316360 $tagClass = 'flaggedrevs_pristine';
317361 } elseif ( $quality ) {
@@ -328,15 +372,18 @@
329373 return true;
330374 }
331375
332 - // For pages that have a stable version, index only that version
 376+ /**
 377+ * If the page has a stable version and it shows by default,
 378+ * tell bots to index only that version of the page.
 379+ * @TODO: what about viewing the draft but when it is synced?
 380+ */
333381 public function setRobotPolicy() {
334382 global $wgOut;
335 - if ( !$this->article->isReviewable() || !$this->article->getStableRev() ) {
 383+ if ( !$this->article->getStableRev() ) {
336384 return true; // page has no stable version
337385 }
338 - if ( !$this->pageOverride() && $this->article->isStableShownByDefault() ) {
339 - # Index the stable version only if it is the default
340 - $wgOut->setRobotPolicy( 'noindex,nofollow' );
 386+ if ( $this->article->isStableShownByDefault() && !$this->showingStable() ) {
 387+ $wgOut->setRobotPolicy( 'noindex,nofollow' ); // don't index this version
341388 }
342389 return true;
343390 }
@@ -781,7 +828,7 @@
782829 $reqId = $wgRequest->getVal( 'stableid' );
783830 if ( $reqId ) {
784831 $frev = FlaggedRevision::newFromTitle( $this->article->getTitle(), $reqId );
785 - } elseif ( $this->pageOverride() ) {
 832+ } elseif ( $this->showingStable() ) {
786833 $frev = $this->article->getStableRev();
787834 }
788835 if ( $frev ) {
@@ -833,10 +880,6 @@
834881 public function addToHistView() {
835882 global $wgOut;
836883 $this->load();
837 - # Must be reviewable. UI may be limited to unobtrusive patrolling system.
838 - if ( !$this->article->isReviewable() ) {
839 - return true;
840 - }
841884 # Add a notice if there are pending edits...
842885 $srev = $this->article->getStableRev();
843886 if ( $srev && $this->article->revsArePending() ) {
@@ -883,7 +926,6 @@
884927 # Show diff to stable, to make things less confusing.
885928 # This can be disabled via user preferences and other conditions...
886929 if ( $frev->getRevId() < $latestId // changes were made
887 - && $this->isDiffShownOnEdit() // stable default and user cannot review
888930 && $wgUser->getBoolOption( 'flaggedrevseditdiffs' ) // not disable via prefs
889931 && $revId == $latestId // only for current rev
890932 && $editPage->section != 'new' // not for new sections
@@ -953,10 +995,9 @@
954996
955997 public function addToNoSuchSection( EditPage $editPage, &$s ) {
956998 $this->load();
957 - if ( !$this->article->isReviewable() ) {
958 - return true; // nothing to do
959 - }
960999 $srev = $this->article->getStableRev();
 1000+ # Add notice for users that may have clicked "edit" for a
 1001+ # section in the stable version that isn't in the draft.
9611002 if ( $srev && $this->article->revsArePending() ) {
9621003 $revsSince = $this->article->getPendingRevCount();
9631004 if ( $revsSince ) {
@@ -1009,10 +1050,8 @@
10101051 if ( !$this->article->exists() || !$this->article->isReviewable() ) {
10111052 return true;
10121053 }
1013 - # Check action and if page is protected
1014 - $action = $wgRequest->getVal( 'action', 'view' );
1015 - # Must be view action...diffs handled elsewhere
1016 - if ( !self::isViewAction( $action ) ) {
 1054+ # Must be a page view action...
 1055+ if ( !$this->isPageViewOrDiff( $wgRequest ) ) {
10171056 return true;
10181057 }
10191058 # Get the revision being displayed
@@ -1155,15 +1194,13 @@
11561195 }
11571196 # Add "pending changes" tab if the page is not synced
11581197 if ( !$synced ) {
1159 - $this->addDraftTab( $views, $srev, $action, $type );
 1198+ $this->addDraftTab( $views, $srev, $type );
11601199 }
11611200 return true;
11621201 }
11631202
11641203 // Add "pending changes" tab and set tab selection CSS
1165 - protected function addDraftTab(
1166 - array &$views, FlaggedRevision $srev, $action, $type
1167 - ) {
 1204+ protected function addDraftTab( array &$views, FlaggedRevision $srev, $type ) {
11681205 global $wgRequest, $wgOut;
11691206 $title = $this->article->getTitle(); // convenience
11701207 $tabs = array(
@@ -1179,10 +1216,10 @@
11801217 ),
11811218 );
11821219 // Set tab selection CSS
1183 - if ( $this->pageOverride() || $wgRequest->getVal( 'stableid' ) ) {
 1220+ if ( $this->showingStable() || $wgRequest->getVal( 'stableid' ) ) {
11841221 // We are looking a the stable version or an old reviewed one
11851222 $tabs['read']['class'] = 'selected';
1186 - } elseif ( self::isViewAction( $action ) ) {
 1223+ } elseif ( $this->isPageViewOrDiff( $wgRequest ) ) {
11871224 $ts = null;
11881225 if ( $wgOut->getRevisionId() ) { // @TODO: avoid same query in Skin.php
11891226 $ts = ( $wgOut->getRevisionId() == $this->article->getLatest() )
@@ -1574,11 +1611,7 @@
15751612 public function injectPostEditURLParams( &$sectionAnchor, &$extraQuery ) {
15761613 global $wgUser;
15771614 $this->load();
1578 - # Don't show this for pages that are not reviewable
1579 - if ( !$this->article->isReviewable() ) {
1580 - return true;
1581 - }
1582 - # Get the stable version, from master
 1615+ # Get the stable version from the master
15831616 $frev = $this->article->getStableRev( FR_MASTER );
15841617 if ( !$frev ) {
15851618 return true;
@@ -1594,7 +1627,7 @@
15951628 $extraQuery .= $extraQuery ? '&' : '';
15961629 // Override diffonly setting to make sure the content is shown
15971630 $extraQuery .= 'oldid=' . $frev->getRevId() . '&diff=cur&diffonly=0&shownotice=1';
1598 - // ...otherwise, go to the current revision after completing an edit.
 1631+ // ...otherwise, go to the draft revision after completing an edit.
15991632 // This allows for users to immediately see their changes.
16001633 } else {
16011634 $extraQuery .= $extraQuery ? '&' : '';
@@ -1792,7 +1825,7 @@
17931826 ? $article->getOldID()
17941827 : $wgRequest->getInt( 'baseRevId' ); // e.g. "show changes"/"preview"
17951828 }
1796 - # Zero oldid => current revision
 1829+ # Zero oldid => draft revision
17971830 if ( !$revId ) {
17981831 $revId = $latestId;
17991832 }

Follow-up revisions

RevisionCommit summaryAuthorDate
r81874* Removed 'noindex,nofollow' for draft versions that are synced with the stab...aaron03:00, 10 February 2011

Status & tagging log