Index: trunk/extensions/FlaggedRevs/FlaggedRevs.php |
— | — | @@ -122,8 +122,6 @@ |
123 | 123 | # Set to false to disable this |
124 | 124 | $wgFlaggedRevsAutopromote = array('days' => 60, 'edits' => 500, 'email' => true); |
125 | 125 | |
126 | | -# What icons to display |
127 | | - |
128 | 126 | # Settings below this point should probably not be modified |
129 | 127 | ############ |
130 | 128 | |
— | — | @@ -140,9 +138,9 @@ |
141 | 139 | global $wgFlaggedRevTags, $wgFlaggedRevValues; |
142 | 140 | |
143 | 141 | $this->dimensions = array(); |
144 | | - foreach ( array_keys($wgFlaggedRevTags) as $tag ) { |
| 142 | + foreach( array_keys($wgFlaggedRevTags) as $tag ) { |
145 | 143 | $this->dimensions[$tag] = array(); |
146 | | - for ($i=0; $i <= $wgFlaggedRevValues; $i++) { |
| 144 | + for($i=0; $i <= $wgFlaggedRevValues; $i++) { |
147 | 145 | $this->dimensions[$tag][$i] = "$tag-$i"; |
148 | 146 | } |
149 | 147 | } |
— | — | @@ -150,22 +148,24 @@ |
151 | 149 | |
152 | 150 | /** |
153 | 151 | * @param string $text |
154 | | - * @returns string |
| 152 | + * @returns array( string, bool ) |
155 | 153 | * All included pages/arguments are expanded out |
156 | 154 | */ |
157 | | - public static function expandText( $text, $title, $id=null ) { |
| 155 | + public static function expandText( $text='', $title, $id=null ) { |
158 | 156 | global $wgParser; |
159 | | - |
160 | | - $text = $text ? $text : ''; |
161 | | - $wgParser->isStable = true; // Causes our hooks to trigger |
162 | | - |
| 157 | + # Causes our hooks to trigger |
| 158 | + $wgParser->isStable = true; |
| 159 | + $wgParser->includesMatched = true; |
| 160 | + # Parse with default options |
163 | 161 | $options = new ParserOptions; |
164 | | - $options->setRemoveComments( true ); // Less banwidth? |
| 162 | + $options->setRemoveComments( true ); // Save some bandwidth ;) |
165 | 163 | $outputText = $wgParser->preprocess( $text, $title, $options, $id ); |
| 164 | + $expandedText = array( $outputText, $wgParser->includesMatched ); |
| 165 | + # Done! |
| 166 | + $wgParser->isStable = false; |
| 167 | + $wgParser->includesMatched = false; |
166 | 168 | |
167 | | - $wgParser->isStable = false; // Done! |
168 | | - |
169 | | - return $outputText; |
| 169 | + return $expandedText; |
170 | 170 | } |
171 | 171 | |
172 | 172 | /** |
— | — | @@ -407,12 +407,13 @@ |
408 | 408 | |
409 | 409 | public static function ReviewNotes( $row ) { |
410 | 410 | global $wgUser, $wgFlaggedRevComments; |
411 | | - $notes = ''; |
412 | | - if( !$row || !$wgFlaggedRevComments) return $notes; |
413 | 411 | |
| 412 | + if( !$row || !$wgFlaggedRevComments ) |
| 413 | + return $notes; |
| 414 | + |
414 | 415 | if( $row->fr_comment ) { |
415 | 416 | $skin = $wgUser->getSkin(); |
416 | | - $notes .= '<p><div class="flaggedrevs_notes plainlinks">'; |
| 417 | + $notes = '<p><div class="flaggedrevs_notes plainlinks">'; |
417 | 418 | $notes .= wfMsgExt('revreview-note', array('parse'), User::whoIs( $row->fr_user ) ); |
418 | 419 | $notes .= '<i>' . $skin->formatComment( $row->fr_comment ) . '</i></div></p><br/>'; |
419 | 420 | } |
— | — | @@ -676,21 +677,17 @@ |
677 | 678 | // Trigger for stable version parsing only |
678 | 679 | if( !isset($parser->isStable) || !$parser->isStable ) |
679 | 680 | return true; |
680 | | - |
681 | | - $dbr = wfGetDB( DB_SLAVE ); |
682 | | - $id = $dbr->selectField('flaggedtemplates', 'ft_tmp_rev_id', |
683 | | - array('ft_rev_id' => $parser->mRevisionId, |
| 681 | + // Only called to make fr_text, right after template/image specifiers |
| 682 | + // are added to the DB. It's unlikely for slaves to have it yet |
| 683 | + $dbw = wfGetDB( DB_MASTER ); |
| 684 | + $id = $dbw->selectField('flaggedtemplates', 'ft_tmp_rev_id', |
| 685 | + array('ft_rev_id' => $parser->mRevisionId, |
684 | 686 | 'ft_namespace' => $title->getNamespace(), 'ft_title' => $title->getDBkey() ), |
685 | 687 | __METHOD__ ); |
686 | | - // Slave lag maybe? try master... |
687 | | - if( $id===false ) { |
688 | | - $dbw = wfGetDB( DB_MASTER ); |
689 | | - $id = $dbw->selectField('flaggedtemplates', 'ft_tmp_rev_id', |
690 | | - array('ft_rev_id' => $parser->mRevisionId, |
691 | | - 'ft_namespace' => $title->getNamespace(), 'ft_title' => $title->getDBkey() ), |
692 | | - __METHOD__ ); |
693 | | - } |
| 688 | + |
694 | 689 | if( !$id ) { |
| 690 | + if( $id === false ) |
| 691 | + $parser->includesMatched = false; // May want to give an error |
695 | 692 | $id = 0; // Zero for not found |
696 | 693 | $skip = true; |
697 | 694 | } |
— | — | @@ -702,18 +699,16 @@ |
703 | 700 | if( !isset($parser->isStable) || !$parser->isStable ) |
704 | 701 | return true; |
705 | 702 | |
706 | | - $dbr = wfGetDB( DB_SLAVE ); |
707 | | - $time = $dbr->selectField('flaggedimages', 'fi_img_timestamp', |
| 703 | + // Only called to make fr_text, right after template/image specifiers |
| 704 | + // are added to the DB. It's unlikely for slaves to have it yet |
| 705 | + $dbw = wfGetDB( DB_MASTER ); |
| 706 | + $time = $dbw->selectField('flaggedimages', 'fi_img_timestamp', |
708 | 707 | array('fi_rev_id' => $parser->mRevisionId, 'fi_name' => $nt->getDBkey() ), |
709 | 708 | __METHOD__ ); |
710 | | - // Slave lag maybe? try master... |
711 | | - if( $time===false ) { |
712 | | - $dbw = wfGetDB( DB_MASTER ); |
713 | | - $time = $dbw->selectField('flaggedimages', 'fi_img_timestamp', |
714 | | - array('fi_rev_id' => $parser->mRevisionId, 'fi_name' => $nt->getDBkey() ), |
715 | | - __METHOD__ ); |
716 | | - } |
| 709 | + |
717 | 710 | if( !$time ) { |
| 711 | + if( $time === false ) |
| 712 | + $parser->includesMatched = false; // May want to give an error |
718 | 713 | $time = 0; // Zero for not found |
719 | 714 | $skip = true; |
720 | 715 | } |
— | — | @@ -1214,8 +1209,7 @@ |
1215 | 1210 | $form .= wfHidden( 'oldid', $id ); |
1216 | 1211 | $form .= wfHidden( 'action', 'submit'); |
1217 | 1212 | $form .= wfHidden( 'wpEditToken', $wgUser->editToken() ); |
1218 | | - // It takes time to review, make sure that we record what the reviewer had in mind |
1219 | | - $form .= wfHidden( 'wpTimestamp', wfTimestampNow() ); |
| 1213 | + |
1220 | 1214 | foreach( $this->dimensions as $quality => $levels ) { |
1221 | 1215 | $options = ''; $disabled = ''; |
1222 | 1216 | foreach( $levels as $idx => $label ) { |
Index: trunk/extensions/FlaggedRevs/FlaggedRevsPage.body.php |
— | — | @@ -52,8 +52,6 @@ |
53 | 53 | // Special parameter mapping |
54 | 54 | $this->templateParams = $wgRequest->getVal( 'templateParams' ); |
55 | 55 | $this->imageParams = $wgRequest->getVal( 'imageParams' ); |
56 | | - // Time of page view when viewed |
57 | | - $this->timestamp = $wgRequest->getVal( 'wpTimestamp' ); |
58 | 56 | // Log comment |
59 | 57 | $this->comment = $wgRequest->getText( 'wpReason' ); |
60 | 58 | // Additional notes |
— | — | @@ -123,8 +121,8 @@ |
124 | 122 | * @param webrequest $request |
125 | 123 | */ |
126 | 124 | function showRevision( $request ) { |
127 | | - global $wgOut, $wgUser, $wgTitle, |
128 | | - $wgFlaggedRevComments, $wgFlaggedRevTags, $wgFlaggedRevValues; |
| 125 | + global $wgOut, $wgUser, $wgTitle, $wgFlaggedRevComments, $wgFlaggedRevsOverride, |
| 126 | + $wgFlaggedRevTags, $wgFlaggedRevValues; |
129 | 127 | |
130 | 128 | if ( !$this->isValid ) |
131 | 129 | $wgOut->addWikiText( '<strong>' . wfMsg( 'revreview-toolow' ) . '</strong>' ); |
— | — | @@ -139,11 +137,14 @@ |
140 | 138 | $wgOut->showErrorPage( 'internalerror', 'notargettitle', 'notargettext' ); |
141 | 139 | return; |
142 | 140 | } |
| 141 | + |
143 | 142 | $wgOut->addHtml( "<ul>" ); |
144 | 143 | $wgOut->addHtml( $this->historyLine( $rev ) ); |
145 | 144 | $wgOut->addHtml( "</ul>" ); |
146 | 145 | |
147 | | - $wgOut->addWikiText( wfMsg('revreview-text') ); |
| 146 | + if( $wgFlaggedRevsOverride ) |
| 147 | + $wgOut->addWikiText( wfMsg('revreview-text') ); |
| 148 | + |
148 | 149 | $formradios = array(); |
149 | 150 | // Dynamically contruct our radio options |
150 | 151 | foreach ( array_keys($wgFlaggedRevTags) as $tag ) { |
— | — | @@ -261,7 +262,7 @@ |
262 | 263 | } |
263 | 264 | $wgOut->redirect( $this->page->escapeLocalUrl() ); |
264 | 265 | } else { |
265 | | - $wgOut->showErrorPage( 'internalerror', 'badarticleerror' ); |
| 266 | + $wgOut->showErrorPage( 'internalerror', 'revreview-changed' ); |
266 | 267 | } |
267 | 268 | } |
268 | 269 | |
— | — | @@ -272,18 +273,16 @@ |
273 | 274 | function approveRevision( $rev=NULL, $notes='' ) { |
274 | 275 | global $wgUser, $wgFlaggedRevsWatch, $wgParser; |
275 | 276 | |
276 | | - if( is_null($rev) ) return false; |
277 | | - // No bogus timestamps |
278 | | - if ( $this->timestamp && ($this->timestamp < $rev->getTimestamp() || $this->timestamp > wfTimestampNow()) ) |
| 277 | + if( is_null($rev) ) |
279 | 278 | return false; |
| 279 | + // Get the page this corresponds to |
| 280 | + $title = $rev->getTitle(); |
280 | 281 | |
281 | 282 | $quality = 0; |
282 | 283 | if ( FlaggedRevs::isQuality($this->dims) ) { |
283 | 284 | $quality = FlaggedRevs::getLCQuality($this->dims); |
284 | 285 | $quality = ($quality > 1) ? $quality : 1; |
285 | 286 | } |
286 | | - // Get the page this corresponds to |
287 | | - $title = $rev->getTitle(); |
288 | 287 | // Our flags |
289 | 288 | $flagset = array(); |
290 | 289 | foreach( $this->dims as $tag => $value ) { |
— | — | @@ -301,7 +300,7 @@ |
302 | 301 | if( !$template ) continue; |
303 | 302 | |
304 | 303 | $m = explode('|',$template,2); |
305 | | - if( !isset($m[0]) || !isset($m[1]) || !$m[0] || !$m[1] ) continue; |
| 304 | + if( !isset($m[0]) || !isset($m[1]) || !$m[0] ) continue; |
306 | 305 | |
307 | 306 | list($prefixed_text,$rev_id) = $m; |
308 | 307 | |
— | — | @@ -325,7 +324,7 @@ |
326 | 325 | if( !$image ) continue; |
327 | 326 | $m = explode('|',$image,2); |
328 | 327 | |
329 | | - if( !isset($m[0]) || !isset($m[1]) || !$m[0] || !$m[1] ) continue; |
| 328 | + if( !isset($m[0]) || !isset($m[1]) || !$m[0] ) continue; |
330 | 329 | |
331 | 330 | list($dbkey,$timestamp) = $m; |
332 | 331 | |
— | — | @@ -342,8 +341,8 @@ |
343 | 342 | ); |
344 | 343 | } |
345 | 344 | |
346 | | - wfProfileIn( __METHOD__ ); |
347 | 345 | $dbw = wfGetDB( DB_MASTER ); |
| 346 | + $dbw->begin(); |
348 | 347 | // Update our versioning pointers |
349 | 348 | if( !empty( $tmpset ) ) { |
350 | 349 | $dbw->replace( 'flaggedtemplates', array( array('ft_rev_id','ft_namespace','ft_title') ), $tmpset, |
— | — | @@ -354,14 +353,18 @@ |
355 | 354 | __METHOD__ ); |
356 | 355 | } |
357 | 356 | // Get the page text and resolve all templates |
358 | | - $fulltext = FlaggedRevs::expandText( $rev->getText(), $rev->getTitle(), $rev->getId() ); |
| 357 | + list($fulltext,$complete) = FlaggedRevs::expandText( $rev->getText(), $rev->getTitle(), $rev->getId() ); |
| 358 | + if( !$complete ) { |
| 359 | + $dbw->rollback(); // All versions must be specified, 0 for none |
| 360 | + return false; |
| 361 | + } |
359 | 362 | // Our review entry |
360 | 363 | $revset = array( |
361 | 364 | 'fr_rev_id' => $rev->getId(), |
362 | 365 | 'fr_namespace' => $title->getNamespace(), |
363 | 366 | 'fr_title' => $title->getDBkey(), |
364 | 367 | 'fr_user' => $wgUser->getId(), |
365 | | - 'fr_timestamp' => $this->timestamp, |
| 368 | + 'fr_timestamp' => wfTimestampNow(), |
366 | 369 | 'fr_comment' => $notes, |
367 | 370 | 'fr_text' => $fulltext, // Store expanded text for speed |
368 | 371 | 'fr_quality' => $quality |
— | — | @@ -370,12 +373,13 @@ |
371 | 374 | $dbw->replace( 'flaggedrevs', array( array('fr_rev_id','fr_namespace','fr_title') ), $revset, __METHOD__ ); |
372 | 375 | // Set all of our flags |
373 | 376 | $dbw->replace( 'flaggedrevtags', array( array('frt_rev_id','frt_dimension') ), $flagset, __METHOD__ ); |
374 | | - |
375 | 377 | // Mark as patrolled |
376 | 378 | $dbw->update( 'recentchanges', |
377 | 379 | array( 'rc_patrolled' => 1 ), |
378 | | - array( 'rc_this_oldid' => $rev->getId() ), __METHOD__ |
| 380 | + array( 'rc_this_oldid' => $rev->getId() ), |
| 381 | + __METHOD__ |
379 | 382 | ); |
| 383 | + $dbw->commit(); |
380 | 384 | |
381 | 385 | // Update the article review log |
382 | 386 | $this->updateLog( $this->page, $this->dims, $this->comment, $this->oldid, true ); |
— | — | @@ -389,7 +393,7 @@ |
390 | 394 | $poutput = $wgParser->parse($text, $article->mTitle, ParserOptions::newFromUser($wgUser)); |
391 | 395 | } |
392 | 396 | $u = new LinksUpdate( $this->page, $poutput ); |
393 | | - $u->doUpdate(); // this will trigger our hook to add stable links too... |
| 397 | + $u->doUpdate(); // Will trigger our hook to add stable links too... |
394 | 398 | |
395 | 399 | # Clear the cache... |
396 | 400 | $this->page->invalidateCache(); |
— | — | @@ -398,8 +402,6 @@ |
399 | 403 | # Purge squid for this page only |
400 | 404 | $this->page->purgeSquid(); |
401 | 405 | |
402 | | - wfProfileOut( __METHOD__ ); |
403 | | - |
404 | 406 | return true; |
405 | 407 | } |
406 | 408 | |
Index: trunk/extensions/FlaggedRevs/FlaggedRevsPage.i18n.php |
— | — | @@ -87,7 +87,12 @@ |
88 | 88 | 'revreview-style-3' => 'Concise', |
89 | 89 | 'revreview-style-4' => 'Featured', |
90 | 90 | 'revreview-log' => 'Log comment:', |
91 | | - 'revreview-submit' => 'Apply review', |
| 91 | + 'revreview-submit' => 'Submit review', |
| 92 | + 'revreview-changed' => '\'\'\'The requestion action could not be performed on this revision.\'\'\' |
| 93 | + |
| 94 | + A template or image may have been requested when no specific version was specified. This can happen if a |
| 95 | + dynamic template transcludes another image or template depending on a variable that changed since you started |
| 96 | + reviewed this page. Refreshing the page and rereviewing can solve this problem.', |
92 | 97 | |
93 | 98 | 'stableversions' => 'Stable versions', |
94 | 99 | 'stableversions-leg1' => 'List reviewed revisions for a page', |