Index: trunk/extensions/FlaggedRevs/FlaggedRevs.php |
— | — | @@ -236,8 +236,7 @@ |
237 | 237 | public static function getFlaggedRevText( $rev_id ) { |
238 | 238 | $db = wfGetDB( DB_SLAVE ); |
239 | 239 | // Get the text from the flagged revisions table |
240 | | - $result = $db->select( |
241 | | - array('flaggedrevs','revision'), |
| 240 | + $result = $db->select( array('flaggedrevs','revision'), |
242 | 241 | array('fr_text'), |
243 | 242 | array('fr_rev_id' => $rev_id, 'fr_rev_id = rev_id', 'rev_deleted & '.Revision::DELETED_TEXT.' = 0'), |
244 | 243 | __METHOD__, |
— | — | @@ -257,8 +256,7 @@ |
258 | 257 | public static function getFlaggedRev( $rev_id ) { |
259 | 258 | $db = wfGetDB( DB_SLAVE ); |
260 | 259 | // Skip deleted revisions |
261 | | - $result = $db->select( |
262 | | - array('flaggedrevs','revision'), |
| 260 | + $result = $db->select( array('flaggedrevs','revision'), |
263 | 261 | array('fr_namespace', 'fr_title', 'fr_rev_id', 'fr_user', 'fr_timestamp', 'fr_comment', 'rev_timestamp'), |
264 | 262 | array('fr_rev_id' => $rev_id, 'fr_rev_id = rev_id', 'rev_deleted & '.Revision::DELETED_TEXT.' = 0'), |
265 | 263 | __METHOD__ ); |
— | — | @@ -308,13 +306,13 @@ |
309 | 307 | } |
310 | 308 | |
311 | 309 | /** |
312 | | - * Get latest quality rev, if not, the latest reviewed one |
| 310 | + * Get latest quality rev, if not, the latest reviewed one. |
313 | 311 | * @param Title $title |
314 | 312 | * @param bool $getText |
315 | | - * @param bool $highPriority, use master DB? |
| 313 | + * @param bool $forUpdate, use master DB and avoid using page_ext_stable? |
316 | 314 | * @returns Row |
317 | 315 | */ |
318 | | - public function getOverridingRev( $title=NULL, $getText=false, $highPriority=false ) { |
| 316 | + public function getOverridingRev( $title=NULL, $getText=false, $forUpdate=false ) { |
319 | 317 | if( is_null($title) ) |
320 | 318 | return null; |
321 | 319 | |
— | — | @@ -322,25 +320,39 @@ |
323 | 321 | if( $getText ) |
324 | 322 | $selectColumns[] = 'fr_text'; |
325 | 323 | |
326 | | - $dbr = $highPriority ? wfGetDB( DB_MASTER ) : wfGetDB( DB_SLAVE ); |
| 324 | + if( !$forUpdate ) { |
| 325 | + $dbr = wfGetDB( DB_SLAVE ); |
| 326 | + // Skip deleted revisions |
| 327 | + $result = $dbr->select( array('page', 'flaggedrevs', 'revision'), |
| 328 | + $selectColumns, |
| 329 | + array('page_namespace' => $title->getNamespace(), 'page_title' => $title->getDBkey(), |
| 330 | + 'page_ext_stable = fr_rev_id', 'fr_rev_id = rev_id', 'fr_quality >= 1', |
| 331 | + 'rev_page' => $title->getArticleID(), 'rev_deleted & '.Revision::DELETED_TEXT.' = 0'), |
| 332 | + __METHOD__, |
| 333 | + array('LIMIT' => 1) ); |
| 334 | + if( !$row = $dbr->fetchObject($result) ) |
| 335 | + return null; |
| 336 | + |
| 337 | + return $row; |
| 338 | + } |
| 339 | + |
| 340 | + $dbw = wfGetDB( DB_MASTER ); |
327 | 341 | // Look for quality revision |
328 | | - $result = $dbr->select( |
329 | | - array('flaggedrevs', 'revision'), |
| 342 | + $result = $dbw->select( array('flaggedrevs', 'revision'), |
330 | 343 | $selectColumns, |
331 | 344 | array('fr_namespace' => $title->getNamespace(), 'fr_title' => $title->getDBkey(), 'fr_quality >= 1', |
332 | 345 | 'fr_rev_id = rev_id', 'rev_page' => $title->getArticleID(), 'rev_deleted & '.Revision::DELETED_TEXT.' = 0'), |
333 | 346 | __METHOD__, |
334 | 347 | array('ORDER BY' => 'fr_rev_id DESC', 'LIMIT' => 1 ) ); |
335 | 348 | // Do we have one? If not, try any reviewed revision... |
336 | | - if( !$row = $dbr->fetchObject($result) ) { |
337 | | - $result = $dbr->select( |
338 | | - array('flaggedrevs', 'revision'), |
| 349 | + if( !$row = $dbw->fetchObject($result) ) { |
| 350 | + $result = $dbw->select( array('flaggedrevs', 'revision'), |
339 | 351 | $selectColumns, |
340 | 352 | array('fr_namespace' => $title->getNamespace(), 'fr_title' => $title->getDBkey(), |
341 | 353 | 'fr_rev_id = rev_id', 'rev_page' => $title->getArticleID(), 'rev_deleted & '.Revision::DELETED_TEXT.' = 0'), |
342 | 354 | __METHOD__, |
343 | 355 | array('ORDER BY' => 'fr_rev_id DESC', 'LIMIT' => 1 ) ); |
344 | | - if( !$row = $dbr->fetchObject($result) ) |
| 356 | + if( !$row = $dbw->fetchObject($result) ) |
345 | 357 | return null; |
346 | 358 | } |
347 | 359 | return $row; |
— | — | @@ -613,28 +625,20 @@ |
614 | 626 | |
615 | 627 | return true; |
616 | 628 | } |
617 | | - |
618 | | - /** |
619 | | - * Updates parser cache output to included needed versioning params. |
| 629 | + |
| 630 | + /** |
| 631 | + * @param Article $article |
| 632 | + * @param Integer $rev_id, the stable version rev_id |
| 633 | + * Updates the page_ext_stable and page_ext_reviewed fields |
620 | 634 | */ |
621 | | - public static function maybeUpdateMainCache( $article, &$outputDone, &$pcache ) { |
622 | | - global $wgUser, $action; |
623 | | - // Only trigger on article view for content pages, not for protect/delete/hist |
624 | | - if( !$article || !$article->exists() || !$article->mTitle->isContentPage() || $action !='view' ) |
625 | | - return true; |
626 | | - // User must have review rights |
627 | | - if( !$wgUser->isAllowed( 'review' ) ) |
628 | | - return true; |
629 | | - |
630 | | - $parserCache =& ParserCache::singleton(); |
631 | | - $parserOutput = $parserCache->get( $article, $wgUser ); |
632 | | - if( $parserOutput ) { |
633 | | - // Clear older, incomplete, cached versions |
634 | | - // We need the IDs of templates and timestamps of images used |
635 | | - if( !isset($parserOutput->mTemplateIds) || !isset($parserOutput->mImageSHA1Keys) ) |
636 | | - $article->mTitle->invalidateCache(); |
637 | | - } |
638 | | - return true; |
| 635 | + function updateArticleOn( $article, $rev_id ) { |
| 636 | + $dbw = wfGetDB( DB_MASTER ); |
| 637 | + $dbw->update( 'page', |
| 638 | + array('page_ext_stable' => $rev_id, |
| 639 | + 'page_ext_reviewed' => ($article->getLatest() == $rev_id) ), |
| 640 | + array('page_namespace' => $article->mTitle->getNamespace(), |
| 641 | + 'page_title' => $article->mTitle->getDBkey() ), |
| 642 | + __METHOD__ ); |
639 | 643 | } |
640 | 644 | |
641 | 645 | public static function updateFromMove( $movePageForm, $oldtitle, $newtitle ) { |
— | — | @@ -650,9 +654,9 @@ |
651 | 655 | /** |
652 | 656 | * Clears cache for a page when revisiondelete is used |
653 | 657 | */ |
654 | | - public static function articleLinksUpdate( $title ) { |
| 658 | + public static function articleLinksUpdate( $title, $a=null, $b=null ) { |
655 | 659 | global $wgUser, $wgParser; |
656 | | - |
| 660 | + |
657 | 661 | $article = new Article( $title ); |
658 | 662 | // Update the links tables as the stable version may now be the default page... |
659 | 663 | $parserCache =& ParserCache::singleton(); |
— | — | @@ -672,14 +676,16 @@ |
673 | 677 | /** |
674 | 678 | * Inject stable links on LinksUpdate |
675 | 679 | */ |
676 | | - public function extraLinksUpdate( $linksUpdate ) { |
| 680 | + public static function extraLinksUpdate( $linksUpdate ) { |
| 681 | + global $wgFlaggedRevs; |
| 682 | + |
677 | 683 | $fname = 'FlaggedRevs::extraLinksUpdate'; |
678 | 684 | wfProfileIn( $fname ); |
679 | 685 | |
680 | 686 | if( !$linksUpdate->mTitle->isContentPage() ) |
681 | 687 | return true; |
682 | 688 | # Check if this page has a stable version |
683 | | - $sv = $this->getOverridingRev( $linksUpdate->mTitle, true, true ); |
| 689 | + $sv = $wgFlaggedRevs->getOverridingRev( $linksUpdate->mTitle, true, true ); |
684 | 690 | if( !$sv ) |
685 | 691 | return true; |
686 | 692 | # Parse the revision |
— | — | @@ -688,6 +694,8 @@ |
689 | 695 | # Might as well update the stable cache while we're at it |
690 | 696 | $article = new Article( $linksUpdate->mTitle ); |
691 | 697 | FlaggedRevs::updatePageCache( $article, $parserOutput ); |
| 698 | + # Update page fields |
| 699 | + FlaggedRevs::updateArticleOn( $article, $sv->fr_rev_id ); |
692 | 700 | # Update the links tables to include these |
693 | 701 | # We want the UNION of links between the current |
694 | 702 | # and stable version. Therefore, we only care about |
— | — | @@ -926,6 +934,8 @@ |
927 | 935 | |
928 | 936 | /** |
929 | 937 | * Automatically review an edit and add a log entry in the review log. |
| 938 | + * LinksUpdate was already called via edit operations, so the page |
| 939 | + * fields will be up to date. This updates the stable version. |
930 | 940 | */ |
931 | 941 | public static function autoReviewEdit( $article, $user, $text, $rev, $flags ) { |
932 | 942 | global $wgParser, $parserCache, $wgFlaggedRevsAutoReview, $wgFlaggedRevs; |
— | — | @@ -943,7 +953,8 @@ |
944 | 954 | 'frt_value' => $value |
945 | 955 | ); |
946 | 956 | } |
947 | | - # Parse the text, we cannot rely on cache, may be out of date or not used |
| 957 | + # Parse the text, we cannot rely on cache, may be out of date or not used. |
| 958 | + # Also, we need the expanded text anyway. |
948 | 959 | $options = new ParserOptions; |
949 | 960 | $options->setTidy(true); |
950 | 961 | $poutput = $wgParser->parse( $text, $article->mTitle, $options, true, true, $rev->getID() ); |
— | — | @@ -1015,6 +1026,8 @@ |
1016 | 1027 | |
1017 | 1028 | # Might as well save the stable cache |
1018 | 1029 | $wgFlaggedRevs->updatePageCache( $article, $poutput ); |
| 1030 | + # Update page fields |
| 1031 | + FlaggedRevs::updateArticleOn( $article, $rev->getID() ); |
1019 | 1032 | # Purge squid for this page only |
1020 | 1033 | $article->mTitle->purgeSquid(); |
1021 | 1034 | |
— | — | @@ -1068,6 +1081,29 @@ |
1069 | 1082 | } |
1070 | 1083 | return true; |
1071 | 1084 | } |
| 1085 | + |
| 1086 | + /** |
| 1087 | + * Updates parser cache output to included needed versioning params. |
| 1088 | + */ |
| 1089 | + public static function maybeUpdateMainCache( $article, &$outputDone, &$pcache ) { |
| 1090 | + global $wgUser, $action; |
| 1091 | + // Only trigger on article view for content pages, not for protect/delete/hist |
| 1092 | + if( !$article || !$article->exists() || !$article->mTitle->isContentPage() || $action !='view' ) |
| 1093 | + return true; |
| 1094 | + // User must have review rights |
| 1095 | + if( !$wgUser->isAllowed( 'review' ) ) |
| 1096 | + return true; |
| 1097 | + |
| 1098 | + $parserCache =& ParserCache::singleton(); |
| 1099 | + $parserOutput = $parserCache->get( $article, $wgUser ); |
| 1100 | + if( $parserOutput ) { |
| 1101 | + // Clear older, incomplete, cached versions |
| 1102 | + // We need the IDs of templates and timestamps of images used |
| 1103 | + if( !isset($parserOutput->mTemplateIds) || !isset($parserOutput->mImageSHA1Keys) ) |
| 1104 | + $article->mTitle->invalidateCache(); |
| 1105 | + } |
| 1106 | + return true; |
| 1107 | + } |
1072 | 1108 | |
1073 | 1109 | ######### |
1074 | 1110 | |
— | — | @@ -1612,17 +1648,52 @@ |
1613 | 1649 | * Same params for the sake of inheritance |
1614 | 1650 | * @returns Row |
1615 | 1651 | */ |
1616 | | - function getOverridingRev( $title = NULL, $getText=false, $highPriority=false ) { |
| 1652 | + function getOverridingRev( $title = NULL, $getText=false, $forUpdate=false ) { |
1617 | 1653 | global $wgTitle; |
1618 | 1654 | |
1619 | 1655 | if( !is_null($title) && $title->getArticleID() != $wgTitle->getArticleID() ) |
1620 | 1656 | return null; // wtf? |
1621 | | - |
1622 | | - if( !$row = $this->getLatestQualityRev( $getText ) ) { |
1623 | | - if( !$row = $this->getLatestStableRev( $getText ) ) { |
1624 | | - return null; |
| 1657 | + |
| 1658 | + if( !$forUpdate ) { |
| 1659 | + if( !$row = $this->getLatestQualityRev( $getText ) ) { |
| 1660 | + if( !$row = $this->getLatestStableRev( $getText ) ) { |
| 1661 | + $this->stablefound = false; |
| 1662 | + return null; |
| 1663 | + } |
1625 | 1664 | } |
| 1665 | + $this->stablefound = true; |
| 1666 | + $this->stablerev = $row; |
| 1667 | + return $row; |
1626 | 1668 | } |
| 1669 | + // Cached results available? |
| 1670 | + if( isset($this->stablefound) ) { |
| 1671 | + return ( $this->stablefound ) ? $this->stablerev : null; |
| 1672 | + } |
| 1673 | + |
| 1674 | + $selectColumns = array('fr_rev_id', 'fr_user', 'fr_timestamp', 'fr_comment', 'rev_timestamp'); |
| 1675 | + if( $getText ) |
| 1676 | + $selectColumns[] = 'fr_text'; |
| 1677 | + |
| 1678 | + $dbw = wfGetDB( DB_MASTER ); |
| 1679 | + // Skip deleted revisions |
| 1680 | + $result = $dbw->select( array('page', 'flaggedrevs', 'revision'), |
| 1681 | + $selectColumns, |
| 1682 | + array('page_namespace' => $wgTitle->getNamespace(), 'page_title' => $wgTitle->getDBkey(), |
| 1683 | + 'page_ext_stable = fr_rev_id', 'fr_rev_id = rev_id', 'fr_quality >= 1', |
| 1684 | + 'rev_page' => $wgTitle->getArticleID(), 'rev_deleted & '.Revision::DELETED_TEXT.' = 0'), |
| 1685 | + __METHOD__, |
| 1686 | + array('LIMIT' => 1) ); |
| 1687 | + |
| 1688 | + // Do we have one? |
| 1689 | + if( $row = $dbw->fetchObject($result) ) { |
| 1690 | + $this->stablefound = true; |
| 1691 | + $this->stablerev = $row; |
| 1692 | + return $row; |
| 1693 | + } else { |
| 1694 | + $this->stablefound = false; |
| 1695 | + return null; |
| 1696 | + } |
| 1697 | + |
1627 | 1698 | return $row; |
1628 | 1699 | } |
1629 | 1700 | |
— | — | @@ -1636,8 +1707,8 @@ |
1637 | 1708 | function getLatestQualityRev( $getText=false ) { |
1638 | 1709 | global $wgTitle; |
1639 | 1710 | // Cached results available? |
1640 | | - if( isset($this->stablefound) ) { |
1641 | | - return ( $this->stablefound ) ? $this->stablerev : null; |
| 1711 | + if( isset($this->qualityfound) ) { |
| 1712 | + return ( $this->qualityfound ) ? $this->qualityrev : null; |
1642 | 1713 | } |
1643 | 1714 | |
1644 | 1715 | $selectColumns = array('fr_rev_id', 'fr_user', 'fr_timestamp', 'fr_comment', 'rev_timestamp'); |
— | — | @@ -1646,8 +1717,7 @@ |
1647 | 1718 | |
1648 | 1719 | $dbr = wfGetDB( DB_SLAVE ); |
1649 | 1720 | // Skip deleted revisions |
1650 | | - $result = $dbr->select( |
1651 | | - array('flaggedrevs', 'revision'), |
| 1721 | + $result = $dbr->select( array('flaggedrevs', 'revision'), |
1652 | 1722 | $selectColumns, |
1653 | 1723 | array('fr_namespace' => $wgTitle->getNamespace(), 'fr_title' => $wgTitle->getDBkey(), 'fr_quality >= 1', |
1654 | 1724 | 'fr_rev_id = rev_id', 'rev_page' => $wgTitle->getArticleID(), 'rev_deleted & '.Revision::DELETED_TEXT.' = 0'), |
— | — | @@ -1656,11 +1726,11 @@ |
1657 | 1727 | |
1658 | 1728 | // Do we have one? |
1659 | 1729 | if( $row = $dbr->fetchObject($result) ) { |
1660 | | - $this->stablefound = true; |
1661 | | - $this->stablerev = $row; |
| 1730 | + $this->qualityfound = true; |
| 1731 | + $this->qualityrev = $row; |
1662 | 1732 | return $row; |
1663 | 1733 | } else { |
1664 | | - $this->stablefound = false; |
| 1734 | + $this->qualityfound = false; |
1665 | 1735 | return null; |
1666 | 1736 | } |
1667 | 1737 | } |
— | — | @@ -1686,8 +1756,7 @@ |
1687 | 1757 | |
1688 | 1758 | $dbr = wfGetDB( DB_SLAVE ); |
1689 | 1759 | // Skip deleted revisions |
1690 | | - $result = $dbr->select( |
1691 | | - array('flaggedrevs', 'revision'), |
| 1760 | + $result = $dbr->select( array('flaggedrevs', 'revision'), |
1692 | 1761 | $selectColumns, |
1693 | 1762 | array('fr_namespace' => $wgTitle->getNamespace(), 'fr_title' => $wgTitle->getDBkey(), |
1694 | 1763 | 'fr_rev_id = rev_id', 'rev_page' => $wgTitle->getArticleID(), 'rev_deleted & '.Revision::DELETED_TEXT.' = 0'), |
— | — | @@ -1764,7 +1833,11 @@ |
1765 | 1834 | # Adds table link references to include ones from the stable version |
1766 | 1835 | $wgHooks['LinksUpdateConstructed'][] = array($wgFlaggedArticle, 'extraLinksUpdate'); |
1767 | 1836 | # If a stable version is hidden, move to the next one if possible, and update things |
| 1837 | +# Check on undelete/delete too |
| 1838 | +$wgHooks['ArticleUndelete'][] = array($wgFlaggedArticle, 'articleLinksUpdate'); |
| 1839 | +$wgHooks['ArticleDelete'][] = array($wgFlaggedArticle, 'articleLinksUpdate'); |
1768 | 1840 | $wgHooks['ArticleRevisionVisiblityUpdates'][] = array($wgFlaggedArticle, 'articleLinksUpdate'); |
| 1841 | +$wgHooks['ArticleMergeComplete'][] = array($wgFlaggedArticle, 'articleLinksUpdate'); |
1769 | 1842 | # Update our table NS/Titles when things are moved |
1770 | 1843 | $wgHooks['SpecialMovepageAfterMove'][] = array($wgFlaggedArticle, 'updateFromMove'); |
1771 | 1844 | # Parser hooks, selects the desired images/templates |
Index: trunk/extensions/FlaggedRevs/FlaggedRevs.sql |
— | — | @@ -61,3 +61,10 @@ |
62 | 62 | INDEX (fi_rev_id,fi_name,fi_img_timestamp), |
63 | 63 | INDEX (fi_rev_id,fi_name,fi_img_sha1) |
64 | 64 | ) TYPE=InnoDB; |
| 65 | + |
| 66 | +-- Add page_ext_stable column, similar to page_latest |
| 67 | +-- Add page_ext_upd columns, a boolean for up to date stable versions |
| 68 | +ALTER TABLE /*$wgDBprefix*/page |
| 69 | + ADD page_ext_reviewed bool NULL, |
| 70 | + ADD page_ext_stable int(10) NULL, |
| 71 | + ADD INDEX ext_namespace_reviewed (page_namespace,page_is_redirect,page_ext_reviewed,page_id); |
Index: trunk/extensions/FlaggedRevs/FlaggedRevsPage_body.php |
— | — | @@ -10,7 +10,7 @@ |
11 | 11 | { |
12 | 12 | |
13 | 13 | function Revisionreview() { |
14 | | - SpecialPage::SpecialPage('Revisionreview', 'review'); |
| 14 | + SpecialPage::SpecialPage( 'Revisionreview', 'review' ); |
15 | 15 | } |
16 | 16 | |
17 | 17 | function execute( $par ) { |
— | — | @@ -279,7 +279,7 @@ |
280 | 280 | */ |
281 | 281 | function approveRevision( $rev=NULL, $notes='' ) { |
282 | 282 | global $wgUser, $wgFlaggedRevsWatch, $wgParser; |
283 | | - |
| 283 | + // Skip null edits |
284 | 284 | if( is_null($rev) ) |
285 | 285 | return false; |
286 | 286 | // Get the page this corresponds to |
— | — | @@ -299,8 +299,7 @@ |
300 | 300 | 'frt_value' => $value |
301 | 301 | ); |
302 | 302 | } |
303 | | - |
304 | | - // Hack, our template version pointers |
| 303 | + // Our template version pointers |
305 | 304 | $tmpset = $templates = array(); |
306 | 305 | $templateMap = explode('#',trim($this->templateParams) ); |
307 | 306 | foreach( $templateMap as $template ) { |
— | — | @@ -324,7 +323,7 @@ |
325 | 324 | 'ft_tmp_rev_id' => $rev_id |
326 | 325 | ); |
327 | 326 | } |
328 | | - // Hack, our image version pointers |
| 327 | + // Our image version pointers |
329 | 328 | $imgset = $images = array(); |
330 | 329 | $imageMap = explode('#',trim($this->imageParams) ); |
331 | 330 | foreach( $imageMap as $image ) { |
— | — | @@ -353,7 +352,7 @@ |
354 | 353 | |
355 | 354 | $dbw = wfGetDB( DB_MASTER ); |
356 | 355 | $dbw->begin(); |
357 | | - // Update our versioning pointers |
| 356 | + // Update our versioning params |
358 | 357 | if( !empty( $tmpset ) ) { |
359 | 358 | $dbw->replace( 'flaggedtemplates', array( array('ft_rev_id','ft_namespace','ft_title') ), $tmpset, |
360 | 359 | __METHOD__ ); |
— | — | @@ -430,7 +429,7 @@ |
431 | 430 | $dbw = wfGetDB( DB_MASTER ); |
432 | 431 | // Delete from table |
433 | 432 | $dbw->delete( 'flaggedrevs', array( 'fr_rev_id' => $row->fr_rev_id ) ); |
434 | | - // Wipe versioning pointers |
| 433 | + // Wipe versioning params |
435 | 434 | $dbw->delete( 'flaggedtemplates', array( 'ft_rev_id' => $row->fr_rev_id ) ); |
436 | 435 | $dbw->delete( 'flaggedimages', array( 'fi_rev_id' => $row->fr_rev_id ) ); |
437 | 436 | // And the flags... |
— | — | @@ -765,8 +764,8 @@ |
766 | 765 | function getName() { |
767 | 766 | return 'UnreviewedPages'; |
768 | 767 | } |
769 | | - |
770 | | - function isExpensive( ) { return true; } |
| 768 | + # Note: updateSpecialPages doesn't support extensions, but this is fast anyway |
| 769 | + function isExpensive( ) { return false; } |
771 | 770 | function isSyndicated() { return false; } |
772 | 771 | |
773 | 772 | function getPageHeader( ) { |
— | — | @@ -777,40 +776,29 @@ |
778 | 777 | global $wgContentNamespaces; |
779 | 778 | |
780 | 779 | list($page,$flaggedrevs,$categorylinks) = $dbr->tableNamesN('page','flaggedrevs','categorylinks'); |
| 780 | + # Must be a content page... |
| 781 | + if( is_null($namespace) || !in_array($namespace,$wgContentNamespaces) ) { |
| 782 | + $where = 'page_namespace IN(' . implode(',',$wgContentNamespaces) . ') '; |
| 783 | + } else { |
| 784 | + $where = "page_namespace={$namespace} "; |
| 785 | + } |
| 786 | + # No redirects |
| 787 | + $where .= "AND page_is_redirect=0 "; |
781 | 788 | # We don't like filesorts, so the query methods here will be very different |
782 | 789 | if( !$showOutdated ) { |
783 | | - # Must be a content page... |
784 | | - if( is_null($namespace) || !in_array($namespace,$wgContentNamespaces) ) { |
785 | | - $ns = 'page_namespace IN(' . implode(',',$wgContentNamespaces) . ')'; |
786 | | - } else { |
787 | | - $ns = "page_namespace={$namespace}"; |
788 | | - } |
789 | | - $where = "$ns AND fr_rev_id IS NULL AND page_is_redirect=0"; |
790 | | - $sql = "SELECT page_namespace AS ns,page_title AS title,page_len FROM $page "; |
791 | | - if( $category ) { |
792 | | - $category = str_replace( ' ', '_', $dbr->strencode($category) ); |
793 | | - $where .= " AND cl_from IS NOT NULL"; |
794 | | - $sql .= "LEFT JOIN $categorylinks ON (cl_from = page_id AND cl_to = '{$category}') "; |
795 | | - } |
796 | | - $sql .= "LEFT JOIN $flaggedrevs ON (page_namespace = fr_namespace AND page_title = fr_title) |
797 | | - WHERE ($where) "; |
| 790 | + $where .= "AND page_ext_reviewed IS NULL"; |
798 | 791 | } else { |
799 | | - # Must be a content page... |
800 | | - if( is_null($namespace) || !in_array($namespace,$wgContentNamespaces) ) { |
801 | | - $ns = 'fr_namespace IN(' . implode(',',$wgContentNamespaces) . ')'; |
802 | | - } else { |
803 | | - $ns = "fr_namespace={$namespace}"; |
804 | | - } |
805 | | - $where = "$ns AND page_is_redirect=0"; |
806 | | - $sql = "SELECT fr_namespace AS ns,fr_title AS title,page_len,MAX(fr_rev_id) as oldid FROM $flaggedrevs "; |
807 | | - $sql .= "LEFT JOIN $page ON (fr_namespace = page_namespace AND fr_title = page_title) "; |
808 | | - if( $category ) { |
809 | | - $category = str_replace( ' ', '_', $dbr->strencode($category) ); |
810 | | - $where .= " AND cl_from IS NOT NULL"; |
811 | | - $sql .= "LEFT JOIN $categorylinks ON (cl_from = page_id AND cl_to = '{$category}') "; |
812 | | - } |
813 | | - $sql .= "WHERE ($where) GROUP BY fr_namespace,fr_title HAVING MAX(page_latest) > MAX(fr_rev_id)"; |
| 792 | + $where .= "AND page_ext_reviewed = 0"; |
814 | 793 | } |
| 794 | + $sql = "SELECT page_namespace AS ns,page_title AS title,page_len,page_ext_stable FROM $page "; |
| 795 | + # Filter by category |
| 796 | + if( $category ) { |
| 797 | + $category = str_replace( ' ', '_', $dbr->strencode($category) ); |
| 798 | + $where .= " AND cl_from IS NOT NULL"; |
| 799 | + $sql .= "LEFT JOIN $categorylinks ON (cl_from = page_id AND cl_to = '{$category}') "; |
| 800 | + } |
| 801 | + $sql .= "WHERE ($where) "; |
| 802 | + |
815 | 803 | return $sql; |
816 | 804 | } |
817 | 805 | |
— | — | @@ -836,8 +824,9 @@ |
837 | 825 | else |
838 | 826 | $stxt = ' <small>' . wfMsgHtml('historysize', $wgLang->formatNum( $size ) ) . '</small>'; |
839 | 827 | } |
840 | | - if( isset($result->oldid) ) |
841 | | - $review = ' ('.$skin->makeKnownLinkObj( $title, wfMsg('unreviewed-diff'), "diff=cur&oldid={$result->oldid}" ).')'; |
| 828 | + if( $result->page_ext_stable ) |
| 829 | + $review = ' ('.$skin->makeKnownLinkObj( $title, wfMsg('unreviewed-diff'), |
| 830 | + "diff=cur&oldid={$result->page_ext_stable}&editreview=1" ).')'; |
842 | 831 | |
843 | 832 | return( "{$link} {$stxt} {$review}" ); |
844 | 833 | } |
Index: trunk/extensions/FlaggedRevs/FlaggedRevsPage.i18n.php |
— | — | @@ -114,11 +114,10 @@ |
115 | 115 | |
116 | 116 | 'unreviewedpages' => 'Unreviewed pages', |
117 | 117 | 'viewunreviewed' => 'List unreviewed content pages', |
118 | | - 'unreviewed-outdated' => 'Show only pages that have revisions made since the last review.', |
| 118 | + 'unreviewed-outdated' => 'Show only pages that have unreviewed revisions made to the stable version.', |
119 | 119 | 'unreviewed-category' => 'Category:', |
120 | | - 'unreviewed-diff' => 'Unreviewed changes', |
121 | | - 'unreviewed-list' => 'This page lists articles that have not yet been reviewed or have unreviewed revisions. Note pages |
122 | | - with out of date "quality" revisions will not be listed here if the current revision is "sighted".', |
| 120 | + 'unreviewed-diff' => 'Changes', |
| 121 | + 'unreviewed-list' => 'This page lists articles that have not yet been reviewed or have unreviewed revisions.', |
123 | 122 | ); |
124 | 123 | |
125 | 124 | /* Arabic (Meno25) */ |
Index: trunk/extensions/FlaggedRevs/FlaggedRevs.pg.sql |
— | — | @@ -42,4 +42,9 @@ |
43 | 43 | CREATE INDEX fi_rev_name_time ON flaggedimages (fi_rev_id,fi_name,fi_img_timestamp); |
44 | 44 | CREATE INDEX fi_rev_img_sha1 ON flaggedimages (fi_rev_id,fi_name,fi_img_sha1); |
45 | 45 | |
| 46 | +ALTER TABLE page |
| 47 | + ADD page_ext_reviewed bool NULL, |
| 48 | + ADD page_ext_stable int(10) NULL; |
| 49 | +CREATE INDEX ext_namespace_reviewed ON page (page_namespace,page_is_redirect,page_ext_reviewed,page_id); |
| 50 | + |
46 | 51 | COMMIT; |