Index: trunk/extensions/FlaggedRevs/FlaggedRevs.php |
— | — | @@ -82,7 +82,7 @@ |
83 | 83 | # Below are groups that see the current revision by default. |
84 | 84 | # This makes editing easier since the users always start off |
85 | 85 | # viewing the latest version of pages. |
86 | | -$wgFlaggedRevsExceptions = array( 'user' ); |
| 86 | +$wgFlaggedRevsExceptions = array( 'user' ); // @TODO: remove when ready (and swap pref) |
87 | 87 | |
88 | 88 | # Can users make comments that will show up below flagged revisions? |
89 | 89 | # NOTE: this is NOT the same as the simple log comment |
Index: trunk/extensions/FlaggedRevs/FlaggedArticle.php |
— | — | @@ -81,8 +81,10 @@ |
82 | 82 | * @return bool |
83 | 83 | */ |
84 | 84 | 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 |
87 | 89 | return (bool)$config['override']; |
88 | 90 | } |
89 | 91 | |
— | — | @@ -239,7 +241,7 @@ |
240 | 242 | } |
241 | 243 | |
242 | 244 | /** |
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? |
244 | 246 | * @return bool |
245 | 247 | */ |
246 | 248 | public function lowProfileUI() { |
— | — | @@ -256,8 +258,12 @@ |
257 | 259 | if ( !FlaggedRevs::inReviewNamespace( $this->getTitle() ) ) { |
258 | 260 | return false; |
259 | 261 | } |
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; |
262 | 268 | } |
263 | 269 | |
264 | 270 | /** |
— | — | @@ -279,8 +285,11 @@ |
280 | 286 | */ |
281 | 287 | public function getStableRev( $flags = 0 ) { |
282 | 288 | # 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 | + } |
285 | 294 | $this->stableRev = $srev ? $srev : false; // false => "found nothing" |
286 | 295 | } |
287 | 296 | if ( $this->stableRev ) { |
— | — | @@ -304,13 +313,11 @@ |
305 | 314 | * @param int $flags, FR_MASTER |
306 | 315 | * @return array (select,override) |
307 | 316 | */ |
308 | | - public function getVisibilitySettings( $flags = 0 ) { |
309 | | - # Cached results available? |
| 317 | + public function getStabilitySettings( $flags = 0 ) { |
310 | 318 | if ( !( $flags & FR_MASTER ) && $this->pageConfig !== null ) { |
311 | | - return $this->pageConfig; |
| 319 | + return $this->pageConfig; // use process cache |
312 | 320 | } |
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; |
316 | 323 | } |
317 | 324 | } |
Index: trunk/extensions/FlaggedRevs/FlaggedRevs.class.php |
— | — | @@ -959,7 +959,7 @@ |
960 | 960 | * @param int $flags, FR_MASTER |
961 | 961 | * @returns array (associative) (select,override,autoreview,expiry) |
962 | 962 | */ |
963 | | - public static function getPageVisibilitySettings( Title $title, $flags = 0 ) { |
| 963 | + public static function getPageStabilitySettings( Title $title, $flags = 0 ) { |
964 | 964 | $db = ( $flags & FR_MASTER ) ? |
965 | 965 | wfGetDB( DB_MASTER ) : wfGetDB( DB_SLAVE ); |
966 | 966 | $row = $db->selectRow( 'flaggedpage_config', |
Index: trunk/extensions/FlaggedRevs/forms/PageStabilityForm.php |
— | — | @@ -183,7 +183,7 @@ |
184 | 184 | |
185 | 185 | protected function loadOldConfig() { |
186 | 186 | # 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 ); |
188 | 188 | $this->oldExpiry = $this->oldConfig['expiry'] === 'infinity' |
189 | 189 | ? 'infinite' |
190 | 190 | : wfTimestamp( TS_RFC2822, $this->oldConfig['expiry'] ); |
— | — | @@ -637,4 +637,4 @@ |
638 | 638 | || $oldRow->fpc_expiry != $dbExpiry // ...expiry changed |
639 | 639 | ); |
640 | 640 | } |
641 | | -} |
\ No newline at end of file |
| 641 | +} |
Index: trunk/extensions/FlaggedRevs/FlaggedRevision.php |
— | — | @@ -194,7 +194,7 @@ |
195 | 195 | } |
196 | 196 | # Get visiblity settings... |
197 | 197 | if ( empty( $config ) ) { |
198 | | - $config = FlaggedRevs::getPageVisibilitySettings( $title, $flags ); |
| 198 | + $config = FlaggedRevs::getPageStabilitySettings( $title, $flags ); |
199 | 199 | } |
200 | 200 | if ( !$config['override'] && FlaggedRevs::useOnlyIfProtected() ) { |
201 | 201 | return null; // page is not reviewable; no stable version |
Index: trunk/extensions/FlaggedRevs/FlaggedRevs.hooks.php |
— | — | @@ -539,7 +539,7 @@ |
540 | 540 | if( !FlaggedRevs::inReviewNamespace( $title ) ) { |
541 | 541 | $ret = ''; |
542 | 542 | } else { |
543 | | - $config = FlaggedRevs::getPageVisibilitySettings( $title ); |
| 543 | + $config = FlaggedRevs::getPageStabilitySettings( $title ); |
544 | 544 | $ret = $config['autoreview']; |
545 | 545 | } |
546 | 546 | } |
— | — | @@ -593,10 +593,10 @@ |
594 | 594 | # Don't let users vandalize pages by moving them... |
595 | 595 | if ( $action === 'move' ) { |
596 | 596 | if ( !FlaggedRevs::inReviewNamespace( $title ) || !$title->exists() ) { |
597 | | - return true; |
| 597 | + return true; // extra short-circuit |
598 | 598 | } |
599 | 599 | $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... |
601 | 601 | if ( !$flaggedArticle->isStableShownByDefault() ) { |
602 | 602 | return true; |
603 | 603 | } |
— | — | @@ -621,7 +621,7 @@ |
622 | 622 | } else if ( $action === 'autoreview' || $action === 'review' ) { |
623 | 623 | # Get autoreview restriction settings... |
624 | 624 | $fa = FlaggedArticle::getTitleInstance( $title ); |
625 | | - $config = $fa->getVisibilitySettings(); |
| 625 | + $config = $fa->getStabilitySettings(); |
626 | 626 | # Convert Sysop -> protect |
627 | 627 | $right = ( $config['autoreview'] === 'sysop' ) ? |
628 | 628 | 'protect' : $config['autoreview']; |
— | — | @@ -1390,33 +1390,40 @@ |
1391 | 1391 | if ( !$fa->isReviewable() ) { |
1392 | 1392 | return true; // nothing to do |
1393 | 1393 | } |
| 1394 | + # Viewing an old reviewed version... |
1394 | 1395 | 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... |
1398 | 1404 | $key = wfMemcKey( 'flaggedrevs', 'overrideRedirect', $article->getId() ); |
1399 | 1405 | $tuple = FlaggedRevs::getMemcValue( $wgMemc->get( $key ), $article ); |
1400 | | - if ( is_array( $tuple ) ) { |
| 1406 | + if ( is_array( $tuple ) ) { // cache hit |
1401 | 1407 | 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 |
1416 | 1415 | } |
1417 | 1416 | $data = FlaggedRevs::makeMemcObj( array( $ignoreRedirect, $target ) ); |
1418 | | - $wgMemc->set( $key, $data, $wgParserCacheExpireTime ); |
| 1417 | + $wgMemc->set( $key, $data, $wgParserCacheExpireTime ); // cache results |
1419 | 1418 | } |
| 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(); |
1420 | 1425 | } |
| 1426 | + # Environment (e.g. $wgTitle) will change in MediaWiki::initializeArticle |
| 1427 | + if ( $clearEnvironment ) $view->clear(); |
1421 | 1428 | return true; |
1422 | 1429 | } |
1423 | 1430 | |
— | — | @@ -1824,7 +1831,7 @@ |
1825 | 1832 | array() : array( 'disabled' => 'disabled' ); |
1826 | 1833 | |
1827 | 1834 | # Get the current config/expiry |
1828 | | - $config = FlaggedRevs::getPageVisibilitySettings( $article->getTitle(), FR_MASTER ); |
| 1835 | + $config = FlaggedRevs::getPageStabilitySettings( $article->getTitle(), FR_MASTER ); |
1829 | 1836 | $oldExpirySelect = ( $config['expiry'] == 'infinity' ) ? 'infinite' : 'existing'; |
1830 | 1837 | |
1831 | 1838 | # Load requested restriction level, default to current level... |
Index: trunk/extensions/FlaggedRevs/FlaggedArticleView.php |
— | — | @@ -31,6 +31,14 @@ |
32 | 32 | protected function __clone() { } |
33 | 33 | |
34 | 34 | /* |
| 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 | + /* |
35 | 43 | * Load the global FlaggedArticle instance |
36 | 44 | */ |
37 | 45 | protected function load() { |
— | — | @@ -56,47 +64,71 @@ |
57 | 65 | } |
58 | 66 | |
59 | 67 | /** |
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. |
62 | 72 | * @returns bool |
63 | 73 | */ |
64 | | - public function pageOverride() { |
| 74 | + protected function showingStableAsDefault() { |
65 | 75 | global $wgUser, $wgRequest; |
66 | 76 | $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 ) ) { |
70 | 79 | 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() ) { |
74 | 82 | return false; |
75 | 83 | } |
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 ) ) { |
78 | 90 | return false; |
79 | 91 | } |
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; |
90 | 117 | } |
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 |
96 | 119 | } |
97 | 120 | return false; |
98 | 121 | } |
99 | 122 | |
100 | 123 | /** |
| 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 | + /** |
101 | 133 | * Should this be using a simple icon-based UI? |
102 | 134 | * Check the user's preferences first, using the site settings as the default. |
103 | 135 | * @returns bool |
— | — | @@ -107,19 +139,23 @@ |
108 | 140 | } |
109 | 141 | |
110 | 142 | /** |
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 |
113 | 145 | * @returns bool |
114 | 146 | */ |
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 | + } |
117 | 153 | # Viewer sees current by default (editors, insiders, ect...) ? |
118 | 154 | foreach ( $wgFlaggedRevsExceptions as $group ) { |
119 | 155 | if ( $group == 'user' ) { |
120 | | - if ( $wgUser->getId() ) { |
| 156 | + if ( $user->getId() ) { |
121 | 157 | return true; |
122 | 158 | } |
123 | | - } elseif ( in_array( $group, $wgUser->getGroups() ) ) { |
| 159 | + } elseif ( in_array( $group, $user->getGroups() ) ) { |
124 | 160 | return true; |
125 | 161 | } |
126 | 162 | } |
— | — | @@ -127,36 +163,51 @@ |
128 | 164 | } |
129 | 165 | |
130 | 166 | /** |
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 |
132 | 169 | * @returns bool |
133 | 170 | */ |
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 ); |
141 | 177 | } |
142 | | - |
| 178 | + |
143 | 179 | /** |
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 |
145 | 182 | * @returns bool |
146 | 183 | */ |
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' ); |
151 | 186 | } |
152 | 187 | |
153 | 188 | /** |
| 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 | + /** |
154 | 206 | * Is this a view page action? |
155 | | - * @param $action string |
| 207 | + * @param $action string from MediaWiki::getAction() |
156 | 208 | * @returns bool |
157 | 209 | */ |
158 | 210 | protected static function isViewAction( $action ) { |
159 | | - return ( $action == 'view' || $action == 'purge' || $action == 'render' |
160 | | - || $action == 'historysubmit' ); |
| 211 | + return ( $action == 'view' || $action == 'purge' || $action == 'render' ); |
161 | 212 | } |
162 | 213 | |
163 | 214 | /** |
— | — | @@ -226,25 +277,20 @@ |
227 | 278 | public function setPageContent( &$outputDone, &$useParserCache ) { |
228 | 279 | global $wgRequest, $wgOut, $wgContLang; |
229 | 280 | $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' ) ) { |
233 | 283 | 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() ) { |
236 | 286 | return true; |
237 | 287 | } |
238 | | - # Only trigger for reviewable pages |
239 | | - if ( !$this->article->isReviewable() ) { |
240 | | - return true; |
241 | | - } |
242 | | - $simpleTag = $old = $stable = false; |
243 | 288 | $tag = ''; |
| 289 | + $old = $stable = false; |
244 | 290 | # Check the newest stable version. |
245 | 291 | $srev = $this->article->getStableRev(); |
246 | 292 | $stableId = $srev ? $srev->getRevId() : 0; |
247 | 293 | $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)... |
249 | 295 | $reqId = $this->getRequestedStableId(); |
250 | 296 | if ( $reqId ) { |
251 | 297 | if ( !$stableId ) { |
— | — | @@ -252,8 +298,8 @@ |
253 | 299 | # Treat requesting the stable version by ID as &stable=1 |
254 | 300 | } else if ( $reqId != $stableId ) { |
255 | 301 | $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 ); |
258 | 304 | if ( !$frev ) { |
259 | 305 | $reqId = false; // invalid ID given |
260 | 306 | } |
— | — | @@ -292,8 +338,8 @@ |
293 | 339 | $outputDone = true; # Tell MW that parser output is done |
294 | 340 | $useParserCache = false; |
295 | 341 | // 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() ) { |
298 | 344 | $this->showStableVersion( $srev, $tag, $prot ); |
299 | 345 | $outputDone = true; # Tell MW that parser output is done |
300 | 346 | $useParserCache = false; |
— | — | @@ -309,8 +355,6 @@ |
310 | 356 | $tagClass = 'flaggedrevs_short'; |
311 | 357 | # Collapse the box details on mouseOut |
312 | 358 | $encJS .= ' onmouseout="FlaggedRevs.onBoxMouseOut(event)"'; |
313 | | - } elseif ( $simpleTag ) { |
314 | | - $tagClass = 'flaggedrevs_notice'; |
315 | 359 | } elseif ( $pristine ) { |
316 | 360 | $tagClass = 'flaggedrevs_pristine'; |
317 | 361 | } elseif ( $quality ) { |
— | — | @@ -328,15 +372,18 @@ |
329 | 373 | return true; |
330 | 374 | } |
331 | 375 | |
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 | + */ |
333 | 381 | public function setRobotPolicy() { |
334 | 382 | global $wgOut; |
335 | | - if ( !$this->article->isReviewable() || !$this->article->getStableRev() ) { |
| 383 | + if ( !$this->article->getStableRev() ) { |
336 | 384 | return true; // page has no stable version |
337 | 385 | } |
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 |
341 | 388 | } |
342 | 389 | return true; |
343 | 390 | } |
— | — | @@ -781,7 +828,7 @@ |
782 | 829 | $reqId = $wgRequest->getVal( 'stableid' ); |
783 | 830 | if ( $reqId ) { |
784 | 831 | $frev = FlaggedRevision::newFromTitle( $this->article->getTitle(), $reqId ); |
785 | | - } elseif ( $this->pageOverride() ) { |
| 832 | + } elseif ( $this->showingStable() ) { |
786 | 833 | $frev = $this->article->getStableRev(); |
787 | 834 | } |
788 | 835 | if ( $frev ) { |
— | — | @@ -833,10 +880,6 @@ |
834 | 881 | public function addToHistView() { |
835 | 882 | global $wgOut; |
836 | 883 | $this->load(); |
837 | | - # Must be reviewable. UI may be limited to unobtrusive patrolling system. |
838 | | - if ( !$this->article->isReviewable() ) { |
839 | | - return true; |
840 | | - } |
841 | 884 | # Add a notice if there are pending edits... |
842 | 885 | $srev = $this->article->getStableRev(); |
843 | 886 | if ( $srev && $this->article->revsArePending() ) { |
— | — | @@ -883,7 +926,6 @@ |
884 | 927 | # Show diff to stable, to make things less confusing. |
885 | 928 | # This can be disabled via user preferences and other conditions... |
886 | 929 | if ( $frev->getRevId() < $latestId // changes were made |
887 | | - && $this->isDiffShownOnEdit() // stable default and user cannot review |
888 | 930 | && $wgUser->getBoolOption( 'flaggedrevseditdiffs' ) // not disable via prefs |
889 | 931 | && $revId == $latestId // only for current rev |
890 | 932 | && $editPage->section != 'new' // not for new sections |
— | — | @@ -953,10 +995,9 @@ |
954 | 996 | |
955 | 997 | public function addToNoSuchSection( EditPage $editPage, &$s ) { |
956 | 998 | $this->load(); |
957 | | - if ( !$this->article->isReviewable() ) { |
958 | | - return true; // nothing to do |
959 | | - } |
960 | 999 | $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. |
961 | 1002 | if ( $srev && $this->article->revsArePending() ) { |
962 | 1003 | $revsSince = $this->article->getPendingRevCount(); |
963 | 1004 | if ( $revsSince ) { |
— | — | @@ -1009,10 +1050,8 @@ |
1010 | 1051 | if ( !$this->article->exists() || !$this->article->isReviewable() ) { |
1011 | 1052 | return true; |
1012 | 1053 | } |
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 ) ) { |
1017 | 1056 | return true; |
1018 | 1057 | } |
1019 | 1058 | # Get the revision being displayed |
— | — | @@ -1155,15 +1194,13 @@ |
1156 | 1195 | } |
1157 | 1196 | # Add "pending changes" tab if the page is not synced |
1158 | 1197 | if ( !$synced ) { |
1159 | | - $this->addDraftTab( $views, $srev, $action, $type ); |
| 1198 | + $this->addDraftTab( $views, $srev, $type ); |
1160 | 1199 | } |
1161 | 1200 | return true; |
1162 | 1201 | } |
1163 | 1202 | |
1164 | 1203 | // 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 ) { |
1168 | 1205 | global $wgRequest, $wgOut; |
1169 | 1206 | $title = $this->article->getTitle(); // convenience |
1170 | 1207 | $tabs = array( |
— | — | @@ -1179,10 +1216,10 @@ |
1180 | 1217 | ), |
1181 | 1218 | ); |
1182 | 1219 | // Set tab selection CSS |
1183 | | - if ( $this->pageOverride() || $wgRequest->getVal( 'stableid' ) ) { |
| 1220 | + if ( $this->showingStable() || $wgRequest->getVal( 'stableid' ) ) { |
1184 | 1221 | // We are looking a the stable version or an old reviewed one |
1185 | 1222 | $tabs['read']['class'] = 'selected'; |
1186 | | - } elseif ( self::isViewAction( $action ) ) { |
| 1223 | + } elseif ( $this->isPageViewOrDiff( $wgRequest ) ) { |
1187 | 1224 | $ts = null; |
1188 | 1225 | if ( $wgOut->getRevisionId() ) { // @TODO: avoid same query in Skin.php |
1189 | 1226 | $ts = ( $wgOut->getRevisionId() == $this->article->getLatest() ) |
— | — | @@ -1574,11 +1611,7 @@ |
1575 | 1612 | public function injectPostEditURLParams( &$sectionAnchor, &$extraQuery ) { |
1576 | 1613 | global $wgUser; |
1577 | 1614 | $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 |
1583 | 1616 | $frev = $this->article->getStableRev( FR_MASTER ); |
1584 | 1617 | if ( !$frev ) { |
1585 | 1618 | return true; |
— | — | @@ -1594,7 +1627,7 @@ |
1595 | 1628 | $extraQuery .= $extraQuery ? '&' : ''; |
1596 | 1629 | // Override diffonly setting to make sure the content is shown |
1597 | 1630 | $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. |
1599 | 1632 | // This allows for users to immediately see their changes. |
1600 | 1633 | } else { |
1601 | 1634 | $extraQuery .= $extraQuery ? '&' : ''; |
— | — | @@ -1792,7 +1825,7 @@ |
1793 | 1826 | ? $article->getOldID() |
1794 | 1827 | : $wgRequest->getInt( 'baseRevId' ); // e.g. "show changes"/"preview" |
1795 | 1828 | } |
1796 | | - # Zero oldid => current revision |
| 1829 | + # Zero oldid => draft revision |
1797 | 1830 | if ( !$revId ) { |
1798 | 1831 | $revId = $latestId; |
1799 | 1832 | } |