Index: trunk/extensions/FlaggedRevs/FlaggedRevision.php |
— | — | @@ -51,8 +51,10 @@ |
52 | 52 | */ |
53 | 53 | public static function newFromTitle( $title, $revId, $flags = 0 ) { |
54 | 54 | $columns = self::selectFields(); |
| 55 | + $options = array(); |
55 | 56 | if( $flags & FR_TEXT ) { |
56 | 57 | $columns += self::selectTextFields(); |
| 58 | + $options[] = 'FOR UPDATE'; |
57 | 59 | } |
58 | 60 | $db = $flags & FR_FOR_UPDATE ? wfGetDB( DB_MASTER ) : wfGetDB( DB_SLAVE ); |
59 | 61 | $pageId = $title->getArticleID( $flags & FR_FOR_UPDATE ? GAID_FOR_UPDATE : 0 ); |
— | — | @@ -68,7 +70,8 @@ |
69 | 71 | 'rev_id = fr_rev_id', |
70 | 72 | 'rev_page = fr_page_id', |
71 | 73 | 'rev_deleted & '.Revision::DELETED_TEXT => 0 ), |
72 | | - __METHOD__ ); |
| 74 | + __METHOD__, |
| 75 | + $options ); |
73 | 76 | # Sorted from highest to lowest, so just take the first one if any |
74 | 77 | if( $row ) { |
75 | 78 | return new FlaggedRevision( $title, $row ); |
— | — | @@ -84,8 +87,10 @@ |
85 | 88 | */ |
86 | 89 | public static function newFromStable( $title, $flags=0 ) { |
87 | 90 | $columns = self::selectFields(); |
| 91 | + $options = array(); |
88 | 92 | if( $flags & FR_TEXT ) { |
89 | 93 | $columns += self::selectTextFields(); |
| 94 | + $options[] = 'FOR UPDATE'; |
90 | 95 | } |
91 | 96 | $row = null; |
92 | 97 | # Short-circuit query |
— | — | @@ -104,6 +109,7 @@ |
105 | 110 | if( !$row ) |
106 | 111 | return null; |
107 | 112 | } else { |
| 113 | + $options['ORDER BY'] = 'fr_rev_id DESC'; |
108 | 114 | # Get visiblity settings... |
109 | 115 | $config = FlaggedRevs::getPageVisibilitySettings( $title, $flags & FR_FOR_UPDATE ); |
110 | 116 | $dbw = wfGetDB( DB_MASTER ); |
— | — | @@ -117,7 +123,7 @@ |
118 | 124 | 'rev_page = fr_page_id', |
119 | 125 | 'rev_deleted & '.Revision::DELETED_TEXT => 0), |
120 | 126 | __METHOD__, |
121 | | - array( 'ORDER BY' => 'fr_rev_id DESC') ); |
| 127 | + $options ); |
122 | 128 | # Looks like a plausible revision |
123 | 129 | $row = $prow ? $prow : null; |
124 | 130 | } |
— | — | @@ -136,7 +142,7 @@ |
137 | 143 | 'rev_page = fr_page_id', |
138 | 144 | 'rev_deleted & '.Revision::DELETED_TEXT => 0), |
139 | 145 | __METHOD__, |
140 | | - array( 'ORDER BY' => 'fr_rev_id DESC') ); |
| 146 | + $options ); |
141 | 147 | $row = $qrow ? $qrow : $row; |
142 | 148 | } |
143 | 149 | # Do we have one? If not, try the latest reviewed revision... |
— | — | @@ -148,7 +154,7 @@ |
149 | 155 | 'rev_page = fr_page_id', |
150 | 156 | 'rev_deleted & '.Revision::DELETED_TEXT => 0), |
151 | 157 | __METHOD__, |
152 | | - array( 'ORDER BY' => 'fr_rev_id DESC' ) ); |
| 158 | + $options ); |
153 | 159 | if( !$row ) |
154 | 160 | return null; |
155 | 161 | } |