Index: trunk/extensions/FlaggedRevs/FlaggedRevs.php |
— | — | @@ -40,8 +40,10 @@ |
41 | 41 | |
42 | 42 | if( !defined('FR_FOR_UPDATE') ) |
43 | 43 | define('FR_FOR_UPDATE',1); |
| 44 | +if( !defined('FR_MASTER') ) |
| 45 | + define('FR_MASTER',2); |
44 | 46 | if( !defined('FR_TEXT') ) |
45 | | - define('FR_TEXT',2); |
| 47 | + define('FR_TEXT',3); |
46 | 48 | |
47 | 49 | if( !defined('READER_FEEDBACK_SIZE') ) |
48 | 50 | define('READER_FEEDBACK_SIZE',30); |
Index: trunk/extensions/FlaggedRevs/FlaggedRevision.php |
— | — | @@ -51,12 +51,19 @@ |
52 | 52 | */ |
53 | 53 | public static function newFromTitle( $title, $revId, $flags = 0 ) { |
54 | 54 | $columns = self::selectFields(); |
55 | | - $options = array(); |
| 55 | + # If we want the text, then get the text flags too |
56 | 56 | if( $flags & FR_TEXT ) { |
57 | 57 | $columns += self::selectTextFields(); |
58 | | - $options[] = 'FOR UPDATE'; |
59 | 58 | } |
60 | | - $db = $flags & FR_FOR_UPDATE ? wfGetDB( DB_MASTER ) : wfGetDB( DB_SLAVE ); |
| 59 | + $options = array(); |
| 60 | + # User master/slave as appropriate |
| 61 | + if( $flags & FR_FOR_UPDATE || $flags & FR_MASTER ) { |
| 62 | + $db = wfGetDB( DB_MASTER ); |
| 63 | + if( $flags & FR_FOR_UPDATE ) |
| 64 | + $options[] = 'FOR UPDATE'; |
| 65 | + } else { |
| 66 | + $db = wfGetDB( DB_SLAVE ); |
| 67 | + } |
61 | 68 | $pageId = $title->getArticleID( $flags & FR_FOR_UPDATE ? GAID_FOR_UPDATE : 0 ); |
62 | 69 | # Short-circuit query |
63 | 70 | if( !$pageId ) { |
— | — | @@ -87,18 +94,18 @@ |
88 | 95 | */ |
89 | 96 | public static function newFromStable( $title, $flags = 0 ) { |
90 | 97 | $columns = self::selectFields(); |
91 | | - $options = array(); |
| 98 | + # If we want the text, then get the text flags too |
92 | 99 | if( $flags & FR_TEXT ) { |
93 | 100 | $columns += self::selectTextFields(); |
94 | | - $options[] = 'FOR UPDATE'; |
95 | 101 | } |
| 102 | + $options = array(); |
96 | 103 | $row = null; |
97 | 104 | # Short-circuit query |
98 | 105 | if( !$title->getArticleId() ) { |
99 | 106 | return $row; |
100 | 107 | } |
101 | | - # If we want the text, then get the text flags too |
102 | | - if( !($flags & FR_FOR_UPDATE) ) { |
| 108 | + # User master/slave as appropriate |
| 109 | + if( !($flags & FR_FOR_UPDATE) && !($flags & FR_MASTER) ) { |
103 | 110 | $dbr = wfGetDB( DB_SLAVE ); |
104 | 111 | $row = $dbr->selectRow( array('flaggedpages','flaggedrevs'), |
105 | 112 | $columns, |
— | — | @@ -109,10 +116,12 @@ |
110 | 117 | if( !$row ) |
111 | 118 | return null; |
112 | 119 | } else { |
113 | | - $options['ORDER BY'] = 'fr_rev_id DESC'; |
| 120 | + if( $flags & FR_FOR_UPDATE ) |
| 121 | + $options[] = 'FOR UPDATE'; |
114 | 122 | # Get visiblity settings... |
115 | | - $config = FlaggedRevs::getPageVisibilitySettings( $title, $flags & FR_FOR_UPDATE ); |
| 123 | + $config = FlaggedRevs::getPageVisibilitySettings( $title, true ); |
116 | 124 | $dbw = wfGetDB( DB_MASTER ); |
| 125 | + $options['ORDER BY'] = 'fr_rev_id DESC'; |
117 | 126 | # Look for the latest pristine revision... |
118 | 127 | if( FlaggedRevs::pristineVersions() && $config['select'] != FLAGGED_VIS_LATEST ) { |
119 | 128 | $prow = $dbw->selectRow( array('flaggedrevs','revision'), |
Index: trunk/extensions/FlaggedRevs/FlaggedRevs.hooks.php |
— | — | @@ -630,6 +630,8 @@ |
631 | 631 | $user = User::newFromId( $rev->getUser() ); |
632 | 632 | if( !$wgFlaggedRevsAutoReview || !$user->isAllowed('autoreview') ) |
633 | 633 | return true; |
| 634 | + # If $baseRevId passed in, this is a null edit |
| 635 | + $isNullEdit = $baseRevId ? true : false; |
634 | 636 | # Must be in reviewable namespace |
635 | 637 | $title = $article->getTitle(); |
636 | 638 | if( !FlaggedRevs::isPageReviewable( $title ) ) { |
— | — | @@ -666,19 +668,23 @@ |
667 | 669 | $reviewableNewPage = (bool)$wgFlaggedRevsAutoReviewNew; |
668 | 670 | // Edits to existing pages |
669 | 671 | } else if( $baseRevId ) { |
670 | | - $frev = FlaggedRevision::newFromTitle( $title, $baseRevId, FR_FOR_UPDATE ); |
| 672 | + $frev = FlaggedRevision::newFromTitle( $title, $baseRevId, FR_MASTER ); |
671 | 673 | # If the base revision was not reviewed, check if the previous one was. |
672 | 674 | # This should catch null edits as well as normal ones. |
673 | 675 | if( !$frev ) { |
674 | | - $frev = FlaggedRevision::newFromTitle( $title, $prevRevId, FR_FOR_UPDATE ); |
| 676 | + $frev = FlaggedRevision::newFromTitle( $title, $prevRevId, FR_MASTER ); |
675 | 677 | } |
676 | 678 | } |
677 | 679 | # Is this an edit directly to the stable version? |
678 | 680 | if( $reviewableNewPage || !is_null($frev) ) { |
679 | | - # Assume basic flagging level |
680 | | - $flags = array(); |
681 | | - foreach( FlaggedRevs::getDimensions() as $tag => $minQL ) { |
682 | | - $flags[$tag] = 1; |
| 681 | + # Assume basic flagging level unless this is a null edit |
| 682 | + if( $isNullEdit ) { |
| 683 | + $flags = $frev->getTags(); |
| 684 | + } else { |
| 685 | + $flags = array(); |
| 686 | + foreach( FlaggedRevs::getDimensions() as $tag => $minQL ) { |
| 687 | + $flags[$tag] = 1; |
| 688 | + } |
683 | 689 | } |
684 | 690 | # Review this revision of the page. Let articlesavecomplete hook do rc_patrolled bit... |
685 | 691 | FlaggedRevs::autoReviewEdit( $article, $user, $rev->getText(), $rev, $flags, false ); |