Index: trunk/extensions/FlaggedRevs/frontend/specialpages/actions/Stabilization_body.php |
— | — | @@ -36,8 +36,7 @@ |
37 | 37 | $out->showErrorPage( 'notargettitle', 'notargettext' ); |
38 | 38 | return; |
39 | 39 | } |
40 | | - $this->getSkin()->setRelevantTitle( $title ); |
41 | | - |
| 40 | + |
42 | 41 | $this->form = new PageStabilityGeneralForm( $user ); |
43 | 42 | $form = $this->form; // convenience |
44 | 43 | |
— | — | @@ -114,10 +113,10 @@ |
115 | 114 | $showProtectOptions = ( $scExpiryOptions !== '-' && $form->isAllowed() ); |
116 | 115 | $dropdownOptions = array(); // array of <label,value> |
117 | 116 | # Add the current expiry as a dropdown option |
118 | | - if ( $oldConfig['expiry'] && $oldConfig['expiry'] != 'infinity' ) { |
119 | | - $timestamp = $this->getLanguage()->timeanddate( $oldConfig['expiry'] ); |
120 | | - $d = $this->getLanguage()->date( $oldConfig['expiry'] ); |
121 | | - $t = $this->getLanguage()->time( $oldConfig['expiry'] ); |
| 117 | + if ( $oldConfig['expiry'] && $oldConfig['expiry'] != Block::infinity() ) { |
| 118 | + $timestamp = $this->getLang()->timeanddate( $oldConfig['expiry'] ); |
| 119 | + $d = $this->getLang()->date( $oldConfig['expiry'] ); |
| 120 | + $t = $this->getLang()->time( $oldConfig['expiry'] ); |
122 | 121 | $dropdownOptions[] = array( |
123 | 122 | wfMsg( 'protect-existing-expiry', $timestamp, $d, $t ), 'existing' ); |
124 | 123 | } |
— | — | @@ -240,7 +239,7 @@ |
241 | 240 | </tr>' . Xml::closeElement( 'table' ) . |
242 | 241 | Html::hidden( 'title', $this->getTitle()->getPrefixedDBKey() ) . |
243 | 242 | Html::hidden( 'page', $title->getPrefixedText() ) . |
244 | | - Html::hidden( 'wpEditToken', $this->getUser()->getEditToken() ); |
| 243 | + Html::hidden( 'wpEditToken', $this->getUser()->editToken() ); |
245 | 244 | } else { |
246 | 245 | $s .= Xml::closeElement( 'table' ); |
247 | 246 | } |
Index: trunk/extensions/FlaggedRevs/frontend/specialpages/reports/QualityOversight_body.php |
— | — | @@ -41,7 +41,7 @@ |
42 | 42 | } |
43 | 43 | |
44 | 44 | # Create a LogPager item to get the results and a LogEventsList item to format them... |
45 | | - $loglist = new LogEventsList( $this->getContext()->getSkin(), $out, 0 ); |
| 45 | + $loglist = new LogEventsList( $this->getUser()->getSkin(), $out, 0 ); |
46 | 46 | $pager = new LogPager( $loglist, 'review', $this->user, '', '', $conds ); |
47 | 47 | |
48 | 48 | # Explanatory text |
Index: trunk/extensions/FlaggedRevs/frontend/specialpages/reports/StablePages_body.php |
— | — | @@ -153,7 +153,7 @@ |
154 | 154 | $conds['page_namespace'] = $this->namespace; |
155 | 155 | // Be sure not to include expired items |
156 | 156 | if( $this->indef ) { |
157 | | - $conds['fpc_expiry'] = $this->mDb->getInfinity(); |
| 157 | + $conds['fpc_expiry'] = Block::infinity(); |
158 | 158 | } else { |
159 | 159 | $encCutoff = $this->mDb->addQuotes( $this->mDb->timestamp() ); |
160 | 160 | $conds[] = "fpc_expiry > {$encCutoff}"; |
Index: trunk/extensions/FlaggedRevs/frontend/FlaggedRevsLogView.php |
— | — | @@ -34,8 +34,9 @@ |
35 | 35 | * @return string |
36 | 36 | */ |
37 | 37 | public static function stabilityLogLinks( $title, $timestamp, $params ) { |
| 38 | + global $wgUser; |
38 | 39 | # Add history link showing edits right before the config change |
39 | | - $hist = Linker::link( |
| 40 | + $hist = $wgUser->getSkin()->link( |
40 | 41 | $title, |
41 | 42 | wfMsgHtml( 'hist' ), |
42 | 43 | array(), |
— | — | @@ -96,7 +97,7 @@ |
97 | 98 | * Create revision, diff, and history links for log line entry |
98 | 99 | */ |
99 | 100 | public static function reviewLogLinks( $action, $title, $params ) { |
100 | | - global $wgLang; |
| 101 | + global $wgUser, $wgLang; |
101 | 102 | $links = ''; |
102 | 103 | # Show link to page with oldid=x as well as the diff to the former stable rev. |
103 | 104 | # Param format is <rev id, last stable id, rev timestamp>. |
— | — | @@ -109,7 +110,7 @@ |
110 | 111 | ? 'review-logentry-diff2' // unreviewed |
111 | 112 | : 'review-logentry-diff'; // reviewed |
112 | 113 | $links .= '('; |
113 | | - $links .= Linker::linkKnown( |
| 114 | + $links .= $wgUser->getSkin()->linkKnown( |
114 | 115 | $title, |
115 | 116 | wfMsgHtml( $msg ), |
116 | 117 | array(), |
— | — | @@ -123,7 +124,7 @@ |
124 | 125 | : $params[2]; |
125 | 126 | $time = $wgLang->timeanddate( $ts, true ); |
126 | 127 | $links .= ' ('; |
127 | | - $links .= Linker::linkKnown( |
| 128 | + $links .= $wgUser->getSkin()->linkKnown( |
128 | 129 | $title, |
129 | 130 | wfMsgHtml( 'review-logentry-id', $revId, $time ), |
130 | 131 | array(), |
Index: trunk/extensions/FlaggedRevs/frontend/RejectConfirmationFormUI.php |
— | — | @@ -130,6 +130,7 @@ |
131 | 131 | |
132 | 132 | $form .= '</div>'; |
133 | 133 | |
| 134 | + $skin = $this->form->getUser()->getSkin(); |
134 | 135 | $reviewTitle = SpecialPage::getTitleFor( 'RevisionReview' ); |
135 | 136 | $form .= Xml::openElement( 'form', |
136 | 137 | array( 'method' => 'POST', 'action' => $reviewTitle->getFullUrl() ) ); |
— | — | @@ -145,7 +146,7 @@ |
146 | 147 | 'wpReason', 120, $defaultSummary, array( 'maxlength' => 200 ) ) . "<br />"; |
147 | 148 | $form .= Html::input( 'wpSubmit', wfMsg( 'revreview-reject-confirm' ), 'submit' ); |
148 | 149 | $form .= ' '; |
149 | | - $form .= Linker::link( $this->form->getPage(), wfMsg( 'revreview-reject-cancel' ), |
| 150 | + $form .= $skin->link( $this->form->getPage(), wfMsg( 'revreview-reject-cancel' ), |
150 | 151 | array( 'onClick' => 'history.back(); return history.length <= 1;' ), |
151 | 152 | array( 'oldid' => $this->form->getRefId(), 'diff' => $this->form->getOldId() ) ); |
152 | 153 | $form .= Xml::closeElement( 'form' ); |
Index: trunk/extensions/FlaggedRevs/backend/FRPageConfig.php |
— | — | @@ -32,7 +32,8 @@ |
33 | 33 | */ |
34 | 34 | public static function getVisibilitySettingsFromRow( $row ) { |
35 | 35 | if ( $row ) { |
36 | | - $expiry = wfGetDB( DB_SLAVE )->decodeExpiry( $row->fpc_expiry ); |
| 36 | + # This code should be refactored, now that it's being used more generally. |
| 37 | + $expiry = Block::decodeExpiry( $row->fpc_expiry ); |
37 | 38 | # Only apply the settings if they haven't expired |
38 | 39 | if ( !$expiry || $expiry < wfTimestampNow() ) { |
39 | 40 | $row = null; // expired |
— | — | @@ -48,7 +49,7 @@ |
49 | 50 | $config = array( |
50 | 51 | 'override' => $row->fpc_override ? 1 : 0, |
51 | 52 | 'autoreview' => $level, |
52 | | - 'expiry' => $expiry // TS_MW |
| 53 | + 'expiry' => Block::decodeExpiry( $row->fpc_expiry ) // TS_MW |
53 | 54 | ); |
54 | 55 | # If there are protection levels defined check if this is valid... |
55 | 56 | if ( FlaggedRevs::useProtectionLevels() ) { |
— | — | @@ -95,7 +96,7 @@ |
96 | 97 | $changed = ( $dbw->affectedRows() != 0 ); // did this do anything? |
97 | 98 | # Otherwise, add/replace row if we are not just setting it to the site default |
98 | 99 | } else { |
99 | | - $dbExpiry = $dbw->encodeExpiry( $config['expiry'] ); |
| 100 | + $dbExpiry = Block::encodeExpiry( $config['expiry'], $dbw ); |
100 | 101 | # Get current config... |
101 | 102 | $oldRow = $dbw->selectRow( 'flaggedpage_config', |
102 | 103 | array( 'fpc_override', 'fpc_level', 'fpc_expiry' ), |
Index: trunk/extensions/FlaggedRevs/backend/FlaggedRevs.hooks.php |
— | — | @@ -295,7 +295,7 @@ |
296 | 296 | /** |
297 | 297 | * Check page move and patrol permissions for FlaggedRevs |
298 | 298 | */ |
299 | | - public static function onGetUserPermissionsErrors( Title $title, $user, $action, &$result ) { |
| 299 | + public static function onUserCan( Title $title, $user, $action, &$result ) { |
300 | 300 | if ( $result === false ) { |
301 | 301 | return true; // nothing to do |
302 | 302 | } |
— | — | @@ -336,20 +336,6 @@ |
337 | 337 | $result = false; |
338 | 338 | return false; |
339 | 339 | } |
340 | | - # Respect page protection to handle cases of "review wars". |
341 | | - # If a page is restricted from editing such that a user cannot |
342 | | - # edit it, then said user should not be able to review it. |
343 | | - foreach ( $title->getRestrictions( 'edit' ) as $right ) { |
344 | | - // Backwards compatibility, rewrite sysop -> protect |
345 | | - $right = ( $right === 'sysop' ) ? 'protect' : $right; |
346 | | - if ( $right != '' && !$user->isAllowed( $right ) ) { |
347 | | - // 'editprotected' bypasses this restriction |
348 | | - if ( !$user->isAllowed( 'editprotected' ) ) { |
349 | | - $result = false; |
350 | | - return false; |
351 | | - } |
352 | | - } |
353 | | - } |
354 | 340 | } |
355 | 341 | return true; |
356 | 342 | } |
Index: trunk/extensions/FlaggedRevs/backend/FRInclusionCache.php |
— | — | @@ -19,98 +19,55 @@ |
20 | 20 | ) { |
21 | 21 | global $wgParser, $wgMemc; |
22 | 22 | wfProfileIn( __METHOD__ ); |
23 | | - |
| 23 | + $versions = false; |
24 | 24 | $key = self::getCacheKey( $article->getTitle(), $rev->getId() ); |
25 | | - if ( $regen === 'regen' ) { |
26 | | - $versions = false; // skip cache |
27 | | - } elseif ( $rev->isCurrent() ) { |
28 | | - // Check cache entry against page_touched |
29 | | - $versions = FlaggedRevs::getMemcValue( $wgMemc->get( $key ), $article ); |
30 | | - } else { |
31 | | - // Old revs won't always be invalidated with template/file changes. |
32 | | - // Also, we don't care if page_touched changed due to a direct edit. |
| 25 | + if ( $regen !== 'regen' ) { // check cache |
33 | 26 | $versions = FlaggedRevs::getMemcValue( $wgMemc->get( $key ), $article, 'allowStale' ); |
34 | | - if ( is_array( $versions ) ) { // entry exists |
35 | | - // Sanity check that the cache is reasonably up to date |
36 | | - list( $templates, $files ) = $versions; |
37 | | - if ( self::templatesStale( $templates ) || self::filesStale( $files ) ) { |
38 | | - $versions = false; // no good |
39 | | - } |
40 | | - } |
41 | 27 | } |
42 | | - |
43 | 28 | if ( !is_array( $versions ) ) { // cache miss |
44 | 29 | $pOut = false; |
45 | 30 | if ( $rev->isCurrent() ) { |
46 | 31 | $parserCache = ParserCache::singleton(); |
47 | | - # Try current version parser cache for this user... |
| 32 | + # Try current version parser cache (as anon)... |
48 | 33 | $pOut = $parserCache->get( $article, $article->makeParserOptions( $user ) ); |
49 | | - if ( $pOut == false ) { |
50 | | - # Try current version parser cache for the revision author... |
51 | | - $optsUser = $rev->getUser() |
52 | | - ? User::newFromId( $rev->getUser() ) |
53 | | - : 'canonical'; |
54 | | - $pOut = $parserCache->get( $article, $article->makeParserOptions( $optsUser ) ); |
| 34 | + if ( $pOut == false && $rev->getUser() ) { // try the user who saved the change |
| 35 | + $author = User::newFromId( $rev->getUser() ); |
| 36 | + $pOut = $parserCache->get( $article, $article->makeParserOptions( $author ) ); |
55 | 37 | } |
56 | 38 | } |
57 | 39 | // ParserOutput::mImageTimeKeys wasn't always there |
58 | 40 | if ( $pOut == false || !FlaggedRevs::parserOutputIsVersioned( $pOut ) ) { |
| 41 | + $title = $article->getTitle(); |
| 42 | + $pOpts = ParserOptions::newFromUser( $user ); // Note: tidy off |
59 | 43 | $pOut = $wgParser->parse( |
60 | | - $rev->getText(), |
61 | | - $article->getTitle(), |
62 | | - ParserOptions::newFromUser( $user ), // Note: tidy off |
63 | | - true, |
64 | | - true, |
65 | | - $rev->getId() |
66 | | - ); |
| 44 | + $rev->getText(), $title, $pOpts, true, true, $rev->getId() ); |
67 | 45 | } |
68 | 46 | # Get the template/file versions used... |
69 | 47 | $versions = array( $pOut->getTemplateIds(), $pOut->getFileSearchOptions() ); |
70 | 48 | # Save to cache (check cache expiry for dynamic elements)... |
71 | 49 | $data = FlaggedRevs::makeMemcObj( $versions ); |
72 | 50 | $wgMemc->set( $key, $data, $pOut->getCacheExpiry() ); |
73 | | - } |
74 | | - |
75 | | - wfProfileOut( __METHOD__ ); |
76 | | - return $versions; |
77 | | - } |
78 | | - |
79 | | - protected static function templatesStale( array $tVersions ) { |
80 | | - # Do a link batch query for page_latest... |
81 | | - $lb = new LinkBatch(); |
82 | | - foreach ( $tVersions as $ns => $tmps ) { |
83 | | - foreach ( $tmps as $dbKey => $revIdDraft ) { |
84 | | - $lb->add( $ns, $dbKey ); |
85 | | - } |
86 | | - } |
87 | | - $lb->execute(); |
88 | | - # Check if any of these templates have a newer version |
89 | | - foreach ( $tVersions as $ns => $tmps ) { |
90 | | - foreach ( $tmps as $dbKey => $revIdDraft ) { |
91 | | - $title = Title::makeTitle( $ns, $dbKey ); |
92 | | - if ( $revIdDraft != $title->getLatestRevID() ) { |
93 | | - return true; |
| 51 | + } else { |
| 52 | + $tVersions =& $versions[0]; // templates |
| 53 | + # Do a link batch query for page_latest... |
| 54 | + $lb = new LinkBatch(); |
| 55 | + foreach ( $tVersions as $ns => $tmps ) { |
| 56 | + foreach ( $tmps as $dbKey => $revIdDraft ) { |
| 57 | + $lb->add( $ns, $dbKey ); |
94 | 58 | } |
95 | 59 | } |
96 | | - } |
97 | | - return false; |
98 | | - } |
99 | | - |
100 | | - protected static function filesStale( array $fVersions ) { |
101 | | - # Check if any of these files have a newer version |
102 | | - foreach ( $fVersions as $name => $timeAndSHA1 ) { |
103 | | - $file = wfFindFile( $name ); |
104 | | - if ( $file ) { |
105 | | - if ( $file->getTimestamp() != $timeAndSHA1['time'] ) { |
106 | | - return true; |
| 60 | + $lb->execute(); |
| 61 | + # Update array with the current page_latest values. |
| 62 | + # This kludge is there since $newTemplates (thus $revIdDraft) is cached. |
| 63 | + foreach ( $tVersions as $ns => &$tmps ) { |
| 64 | + foreach ( $tmps as $dbKey => &$revIdDraft ) { |
| 65 | + $title = Title::makeTitle( $ns, $dbKey ); |
| 66 | + $revIdDraft = (int)$title->getLatestRevID(); |
107 | 67 | } |
108 | | - } else { |
109 | | - if ( $timeAndSHA1['time'] ) { |
110 | | - return true; |
111 | | - } |
112 | 68 | } |
113 | 69 | } |
114 | | - return false; |
| 70 | + wfProfileOut( __METHOD__ ); |
| 71 | + return $versions; |
115 | 72 | } |
116 | 73 | |
117 | 74 | /** |
Index: trunk/extensions/FlaggedRevs/business/RevisionReviewForm.php |
— | — | @@ -228,7 +228,10 @@ |
229 | 229 | |
230 | 230 | public function isAllowed() { |
231 | 231 | // Basic permission check |
232 | | - return ( $this->page && $this->page->userCan( 'review' ) ); |
| 232 | + return ( $this->page |
| 233 | + && $this->page->userCan( 'review' ) |
| 234 | + && $this->page->userCan( 'edit' ) |
| 235 | + ); |
233 | 236 | } |
234 | 237 | |
235 | 238 | // implicit dims for binary flag case |
Index: trunk/extensions/FlaggedRevs/business/PageStabilityForm.php |
— | — | @@ -87,7 +87,7 @@ |
88 | 88 | $value = $this->expirySelection; |
89 | 89 | } |
90 | 90 | if ( $value == 'infinite' || $value == 'indefinite' || $value == 'infinity' ) { |
91 | | - $time = 'infinity'; |
| 91 | + $time = Block::infinity(); |
92 | 92 | } else { |
93 | 93 | $unix = strtotime( $value ); |
94 | 94 | # On error returns -1 for PHP <5.1 and false for PHP >=5.1 |
— | — | @@ -188,7 +188,7 @@ |
189 | 189 | */ |
190 | 190 | public function doPreloadParameters() { |
191 | 191 | $oldConfig = $this->getOldConfig(); |
192 | | - if ( $oldConfig['expiry'] == 'infinity' ) { |
| 192 | + if ( $oldConfig['expiry'] == Block::infinity() ) { |
193 | 193 | $this->expirySelection = 'infinite'; // no settings set OR indefinite |
194 | 194 | } else { |
195 | 195 | $this->expirySelection = 'existing'; // settings set and NOT indefinite |
— | — | @@ -217,7 +217,7 @@ |
218 | 218 | $expiry = $this->getExpiry(); |
219 | 219 | if ( $expiry === false ) { |
220 | 220 | return 'stabilize_expiry_invalid'; |
221 | | - } elseif ( $expiry !== 'infinity' && $expiry < wfTimestampNow() ) { |
| 221 | + } elseif ( $expiry !== Block::infinity() && $expiry < wfTimestampNow() ) { |
222 | 222 | return 'stabilize_expiry_old'; |
223 | 223 | } |
224 | 224 | # Update the DB row with the new config... |
Index: trunk/extensions/FlaggedRevs/FlaggedRevs.setup.php |
— | — | @@ -211,7 +211,7 @@ |
212 | 212 | |
213 | 213 | # ######## Other ######### |
214 | 214 | # Determine what pages can be moved and patrolled |
215 | | - $wgHooks['getUserPermissionsErrors'][] = 'FlaggedRevsHooks::onGetUserPermissionsErrors'; |
| 215 | + $wgHooks['getUserPermissionsErrors'][] = 'FlaggedRevsHooks::onUserCan'; |
216 | 216 | # Implicit autoreview rights group |
217 | 217 | $wgHooks['AutopromoteCondition'][] = 'FlaggedRevsHooks::checkAutoPromoteCond'; |
218 | 218 | $wgHooks['UserLoadAfterLoadFromSession'][] = 'FlaggedRevsHooks::setSessionKey'; |