Index: trunk/extensions/FlaggedRevs/FlaggedRevs.php |
— | — | @@ -76,9 +76,10 @@ |
77 | 77 | # How long to cache stable versions? (seconds) |
78 | 78 | $wgFlaggedRevsExpire = 7 * 24 * 3600; |
79 | 79 | # MW can try to dynamically parse text from a timeframe, however |
80 | | -# it does have limitations. Using expanded text cache will avoid |
81 | | -# this issues with regard to transcluded page moves/deletes. However |
82 | | -# messages like {{CURRENTDATE}} will not remain dynamic. |
| 80 | +# it does have limitations when thins such as special:import are used. |
| 81 | +# However messages like {{CURRENTDATE}} will not remain dynamic if |
| 82 | +# $wgUseExpandedCache is true. Conditional template inclusions will |
| 83 | +# also no longer be updated. |
83 | 84 | $wgUseExpandedCache = false; |
84 | 85 | |
85 | 86 | # When setting up new dimensions or levels, you will need to add some |
— | — | @@ -252,9 +253,9 @@ |
253 | 254 | public static function getReviewedRevs( $page ) { |
254 | 255 | wfProfileIn( __METHOD__ ); |
255 | 256 | |
256 | | - $db = wfGetDB( DB_SLAVE ); |
| 257 | + $db = wfGetDB( DB_SLAVE ); |
257 | 258 | $rows = array(); |
258 | | - // Skip deleted revisions |
| 259 | + |
259 | 260 | $result = $db->select( |
260 | 261 | array('flaggedrevs'), |
261 | 262 | array('fr_rev_id','fr_quality'), |
— | — | @@ -276,8 +277,7 @@ |
277 | 278 | wfProfileIn( __METHOD__ ); |
278 | 279 | |
279 | 280 | $db = wfGetDB( DB_SLAVE ); |
280 | | - $count = $db->selectField('revision', |
281 | | - 'COUNT(*)', |
| 281 | + $count = $db->selectField('revision', 'COUNT(*)', |
282 | 282 | array('rev_page' => $page_id, "rev_id > $from_rev"), |
283 | 283 | __METHOD__ ); |
284 | 284 | |
— | — | @@ -299,7 +299,7 @@ |
300 | 300 | array('flaggedrevs', 'revision'), |
301 | 301 | array('fr_rev_id', 'fr_user', 'fr_timestamp', 'fr_comment', 'rev_timestamp'), |
302 | 302 | array('fr_namespace' => $title->getNamespace(), 'fr_title' => $title->getDBkey(), 'fr_quality >= 1', |
303 | | - 'fr_rev_id = rev_id', 'rev_page' => $article->getId(), 'rev_deleted=0'), |
| 303 | + 'fr_rev_id = rev_id', 'rev_page' => $article->getId(), 'rev_deleted = 0'), |
304 | 304 | __METHOD__, |
305 | 305 | array('ORDER BY' => 'fr_rev_id DESC', 'LIMIT' => 1 ) ); |
306 | 306 | // Do we have one? |
— | — | @@ -308,7 +308,7 @@ |
309 | 309 | array('flaggedrevs', 'revision'), |
310 | 310 | array('fr_rev_id', 'fr_user', 'fr_timestamp', 'fr_comment', 'rev_timestamp'), |
311 | 311 | array('fr_namespace' => $title->getNamespace(), 'fr_title' => $title->getDBkey(), 'fr_quality >= 1', |
312 | | - 'fr_rev_id = rev_id', 'rev_page' => $article->getId(), 'rev_deleted=0'), |
| 312 | + 'fr_rev_id = rev_id', 'rev_page' => $article->getId(), 'rev_deleted = 0'), |
313 | 313 | __METHOD__, |
314 | 314 | array('ORDER BY' => 'fr_rev_id DESC', 'LIMIT' => 1 ) ); |
315 | 315 | if( !$row = $dbr->fetchObject($result) ) |
— | — | @@ -464,6 +464,7 @@ |
465 | 465 | } |
466 | 466 | |
467 | 467 | wfProfileOut( $fname ); |
| 468 | + |
468 | 469 | return $value; |
469 | 470 | } |
470 | 471 | |
— | — | @@ -475,13 +476,13 @@ |
476 | 477 | public static function updatePageCache( $article, $parserOutput=NULL ) { |
477 | 478 | global $wgUser, $parserMemc, $wgFlaggedRevsExpire; |
478 | 479 | // Make sure it is valid |
479 | | - if ( is_null($parserOutput) || !$article ) |
480 | | - return false; |
| 480 | + if ( is_null($parserOutput) || !$article ) return false; |
| 481 | + |
481 | 482 | // Update the cache... |
482 | 483 | $article->mTitle->invalidateCache(); |
483 | 484 | |
484 | 485 | $key = 'sv-' . ParserCache::getKey( $article, $wgUser ); |
485 | | - // Add cache mark to HTML |
| 486 | + // Add cache mark to HTML |
486 | 487 | $now = wfTimestampNow(); |
487 | 488 | $parserOutput->setCacheTime( $now ); |
488 | 489 | |
— | — | @@ -511,17 +512,23 @@ |
512 | 513 | __METHOD__ ); |
513 | 514 | } |
514 | 515 | |
515 | | - public static function extraLinksUpdate( &$article ) { |
| 516 | + public static function extraLinksUpdate( &$title ) { |
516 | 517 | $fname = 'FlaggedRevs::extraLinksUpdate'; |
517 | 518 | wfProfileIn( $fname ); |
| 519 | + |
| 520 | + $article = new Article( $title ); |
| 521 | + if( !$article ) return; |
518 | 522 | # Check if this page has a stable version |
519 | 523 | $sv = self::getOverridingPageRev( $article ); |
520 | | - if ( !$sv ) return; |
| 524 | + if( !$sv ) return; |
521 | 525 | # Retrieve the text |
522 | 526 | $text = self::getFlaggedRevText( $sv->fr_rev_id ); |
523 | 527 | # Parse the revision |
524 | | - $options = ParserOptions::newFromUser($wgUser); |
| 528 | + $options = new ParserOptions; |
525 | 529 | $poutput = self::parseStableText( $article->mTitle, $text, $sv->fr_rev_id, $options, $sv->fr_timestamp ); |
| 530 | + |
| 531 | + # Might as well update the cache while we're at it |
| 532 | + FlaggedRevs::updatePageCache( $article, $poutput ); |
526 | 533 | |
527 | 534 | # Update the links tables to include these |
528 | 535 | # We want the UNION of links between the current |
— | — | @@ -916,16 +923,18 @@ |
917 | 924 | } |
918 | 925 | |
919 | 926 | function addToDiff( &$diff, &$oldrev, &$newrev ) { |
920 | | - $id = $newrev->getId(); |
921 | | - // We cannot review deleted edits |
922 | | - if( $newrev->mDeleted ) return; |
923 | | - $this->addQuickReview( $id ); |
| 927 | + $id = $newrev->getId(); |
| 928 | + // We cannot review deleted edits |
| 929 | + if( !$newrev->mDeleted ) |
| 930 | + $this->addQuickReview( $id ); |
924 | 931 | } |
925 | 932 | |
926 | 933 | function addToPageHist( &$article ) { |
927 | 934 | $this->pageFlaggedRevs = array(); |
928 | 935 | $rows = $this->getReviewedRevs( $article->getTitle() ); |
| 936 | + |
929 | 937 | if( !$rows ) return; |
| 938 | + |
930 | 939 | foreach( $rows as $rev => $quality ) { |
931 | 940 | $this->pageFlaggedRevs[$rev] = $quality; |
932 | 941 | } |
— | — | @@ -989,7 +998,7 @@ |
990 | 999 | array('flaggedrevs', 'revision'), |
991 | 1000 | array('fr_rev_id', 'fr_user', 'fr_timestamp', 'fr_comment', 'rev_timestamp'), |
992 | 1001 | array('fr_namespace' => $title->getNamespace(), 'fr_title' => $title->getDBkey(), 'fr_quality >= 1', |
993 | | - 'fr_rev_id = rev_id', 'rev_page' => $article->getId(), 'rev_deleted=0'), |
| 1002 | + 'fr_rev_id = rev_id', 'rev_page' => $article->getId(), 'rev_deleted = 0'), |
994 | 1003 | __METHOD__, |
995 | 1004 | array('ORDER BY' => 'fr_rev_id DESC', 'LIMIT' => 1 ) ); |
996 | 1005 | // Do we have one? |
— | — | @@ -1030,7 +1039,7 @@ |
1031 | 1040 | array('flaggedrevs', 'revision'), |
1032 | 1041 | array('fr_rev_id', 'fr_user', 'fr_timestamp', 'fr_comment', 'rev_timestamp'), |
1033 | 1042 | array('fr_namespace' => $title->getNamespace(), 'fr_title' => $title->getDBkey(), |
1034 | | - 'fr_rev_id = rev_id', 'rev_page' => $article->getId(), 'rev_deleted=0'), |
| 1043 | + 'fr_rev_id = rev_id', 'rev_page' => $article->getId(), 'rev_deleted = 0'), |
1035 | 1044 | __METHOD__, |
1036 | 1045 | array('ORDER BY' => 'fr_rev_id DESC', 'LIMIT' => 1 ) ); |
1037 | 1046 | // Do we have one? |
— | — | @@ -1093,7 +1102,7 @@ |
1094 | 1103 | |
1095 | 1104 | $wgHooks['ArticleSaveComplete'][] = array($flaggedrevs, 'autoPromoteUser'); |
1096 | 1105 | |
1097 | | -$wgHooks['ArticleEditUpdatesDeleteFromRecentchanges'][] = array($flaggedrevs, 'extraLinksUpdate'); |
| 1106 | +$wgHooks['TitleLinkUpdatesAfterCompletion'][] = array($flaggedrevs, 'extraLinksUpdate'); |
1098 | 1107 | $wgHooks['ArticleRevisionVisiblityUpdates'][] = array($flaggedrevs, 'extraLinksUpdate'); |
1099 | 1108 | $wgHooks['SpecialMovepageAfterMove'][] = array($flaggedrevs, 'updateFromMove'); |
1100 | 1109 | ?> |
Index: trunk/extensions/FlaggedRevs/FlaggedRevsPage.body.php |
— | — | @@ -289,10 +289,21 @@ |
290 | 290 | // Update the article review log |
291 | 291 | $this->updateLog( $this->page, $this->dims, $this->comment, $this->oldid, true ); |
292 | 292 | |
293 | | - # Update our links if needed |
294 | 293 | $article = new Article( $this->page ); |
295 | | - FlaggedRevs::extraLinksUpdate( $article ); |
| 294 | + // Update the links tables as a new stable version |
| 295 | + // may now be the default page. |
| 296 | + $parserCache =& ParserCache::singleton(); |
| 297 | + $poutput = $parserCache->get( $article, $wgUser ); |
| 298 | + if ( $poutput==false ) { |
| 299 | + $text = $article->getContent(); |
| 300 | + $poutput = $wgParser->parse($text, $article->mTitle, ParserOptions::newFromUser($wgUser)); |
| 301 | + } |
| 302 | + $u = new LinksUpdate( $this->page, $poutput ); |
| 303 | + $u->doUpdate(); |
296 | 304 | |
| 305 | + # Might as well update the cache while we're at it |
| 306 | + $parserCache->save( $poutput, $article, $wgUser ); |
| 307 | + |
297 | 308 | # Clear the cache... |
298 | 309 | $this->page->invalidateCache(); |
299 | 310 | # Purge squid for this page only |
— | — | @@ -324,10 +335,21 @@ |
325 | 336 | // Update the article review log |
326 | 337 | $this->updateLog( $this->page, $this->dims, $this->comment, $this->oldid, false ); |
327 | 338 | |
328 | | - # Update our links if needed |
329 | 339 | $article = new Article( $this->page ); |
330 | | - FlaggedRevs::extraLinksUpdate( $article ); |
| 340 | + // Update the links tables as a new stable version |
| 341 | + // may now be the default page. |
| 342 | + $parserCache =& ParserCache::singleton(); |
| 343 | + $poutput = $parserCache->get( $article, $wgUser ); |
| 344 | + if ( $poutput==false ) { |
| 345 | + $text = $article->getContent(); |
| 346 | + $poutput = $wgParser->parse($text, $article->mTitle, ParserOptions::newFromUser($wgUser)); |
| 347 | + } |
| 348 | + $u = new LinksUpdate( $this->page, $poutput ); |
| 349 | + $u->doUpdate(); |
331 | 350 | |
| 351 | + # Might as well update the cache while we're at it |
| 352 | + $parserCache->save( $poutput, $article, $wgUser ); |
| 353 | + |
332 | 354 | # Clear the cache... |
333 | 355 | $this->page->invalidateCache(); |
334 | 356 | # Purge squid for this page only |
— | — | @@ -353,10 +375,14 @@ |
354 | 376 | } |
355 | 377 | $rating = ($approve) ? ' [' . implode(', ',$ratings). ']' : ''; |
356 | 378 | // Append comment with action |
| 379 | + // FIXME: do this better |
357 | 380 | $action = wfMsgExt('review-logaction', array('parsemag'), $oldid ); |
358 | | - $comment = ($comment) ? "$action: $comment$rating" : "$action $rating"; |
| 381 | + if( $approve ) |
| 382 | + $comment = ($comment) ? "$action: $comment$rating" : "$action $rating"; |
| 383 | + else |
| 384 | + $comment = ($comment) ? "$action: $comment" : "$action"; |
359 | 385 | |
360 | | - if ( $approve ) { |
| 386 | + if( $approve ) { |
361 | 387 | $log->addEntry( 'approve', $title, $comment ); |
362 | 388 | } else { |
363 | 389 | $log->addEntry( 'unapprove', $title, $comment ); |