Index: trunk/extensions/FlaggedRevs/FlaggedRevs.php |
— | — | @@ -145,10 +145,10 @@ |
146 | 146 | 'days' => 60, # days since registration |
147 | 147 | 'edits' => 250, # total edit count |
148 | 148 | 'excludeDeleted' => true, # exclude deleted edits from 'edits' count above? |
| 149 | + 'excludeLastDays' => 1, # exclude last X days of edits from 'edits' count above |
149 | 150 | // Require 'benchmark' edits 'spacing' days apart from each other |
150 | 151 | 'spacing' => 3, # spacing of edit intervals |
151 | 152 | 'benchmarks' => 15, # how many edit intervals are needed? |
152 | | - 'recentContentEdits' => 0, # $wgContentNamespaces edits in recent changes |
153 | 153 | // Either totalContentEdits reqs OR totalCheckedEdits requirements needed |
154 | 154 | 'totalContentEdits' => 300, # $wgContentNamespaces edits OR... |
155 | 155 | 'totalCheckedEdits' => 200, # ...Edits before the stable version of pages |
Index: trunk/extensions/FlaggedRevs/FlaggedRevs.hooks.php |
— | — | @@ -1227,12 +1227,12 @@ |
1228 | 1228 | return true; |
1229 | 1229 | } |
1230 | 1230 | } |
| 1231 | + $dbr = wfGetDB( DB_SLAVE ); |
1231 | 1232 | # See if the page actually has sufficient content... |
1232 | 1233 | if ( $wgFlaggedRevsAutopromote['userpageBytes'] > 0 ) { |
1233 | 1234 | if ( !$user->getUserPage()->exists() ) { |
1234 | 1235 | return true; |
1235 | 1236 | } |
1236 | | - $dbr = isset( $dbr ) ? $dbr : wfGetDB( DB_SLAVE ); |
1237 | 1237 | $size = $dbr->selectField( 'page', 'page_len', |
1238 | 1238 | array( 'page_namespace' => $user->getUserPage()->getNamespace(), |
1239 | 1239 | 'page_title' => $user->getUserPage()->getDBkey() ), |
— | — | @@ -1265,48 +1265,38 @@ |
1266 | 1266 | } |
1267 | 1267 | } |
1268 | 1268 | } |
1269 | | - # Check if the user has any recent content edits |
1270 | | - if ( $wgFlaggedRevsAutopromote['recentContentEdits'] > 0 ) { |
1271 | | - global $wgContentNamespaces; |
1272 | | - |
1273 | | - $dbr = isset( $dbr ) ? $dbr : wfGetDB( DB_SLAVE ); |
1274 | | - $res = $dbr->select( 'recentchanges', '1', |
1275 | | - array( 'rc_user_text' => $user->getName(), |
1276 | | - 'rc_namespace' => $wgContentNamespaces ), |
1277 | | - __METHOD__, |
1278 | | - array( 'USE INDEX' => 'rc_ns_usertext', |
1279 | | - 'LIMIT' => $wgFlaggedRevsAutopromote['recentContentEdits'] ) |
1280 | | - ); |
1281 | | - if ( $dbr->numRows( $res ) < $wgFlaggedRevsAutopromote['recentContentEdits'] ) { |
1282 | | - return true; |
1283 | | - } |
1284 | | - } |
| 1269 | + $deletedEdits = $recentEdits = 0; |
| 1270 | + # Get one plus the surplus of edits needed |
| 1271 | + $minDiff = $user->getEditCount() - $wgFlaggedRevsAutopromote['edits'] + 1; |
1285 | 1272 | # Check to see if the user has so many deleted edits that |
1286 | 1273 | # they don't actually enough live edits. This is because |
1287 | 1274 | # $user->getEditCount() is the count of edits made, not live. |
1288 | | - if ( $wgFlaggedRevsAutopromote['excludeDeleted'] ) { |
1289 | | - $dbr = isset( $dbr ) ? $dbr : wfGetDB( DB_SLAVE ); |
1290 | | - $minDiff = $user->getEditCount() - $wgFlaggedRevsAutopromote['days'] + 1; |
1291 | | - # Use an estimate if the number starts to get large |
1292 | | - if ( $minDiff <= 100 ) { |
1293 | | - $res = $dbr->select( 'archive', '1', |
1294 | | - array( 'ar_user_text' => $user->getName() ), |
1295 | | - __METHOD__, |
1296 | | - array( 'USE INDEX' => 'usertext_timestamp', 'LIMIT' => $minDiff ) ); |
1297 | | - $deletedEdits = $dbr->numRows( $res ); |
1298 | | - } else { |
1299 | | - $deletedEdits = $dbr->estimateRowCount( 'archive', '1', |
1300 | | - array( 'ar_user_text' => $user->getName() ), |
1301 | | - __METHOD__, |
1302 | | - array( 'USE INDEX' => 'usertext_timestamp' ) ); |
1303 | | - } |
1304 | | - if ( $deletedEdits >= $minDiff ) { |
1305 | | - return true; |
1306 | | - } |
| 1275 | + # NOTE: check skipped if the query gets large (due to high edit count surplus) |
| 1276 | + if ( $wgFlaggedRevsAutopromote['excludeDeleted'] && $minDiff <= 200 ) { |
| 1277 | + $res = $dbr->select( 'archive', '1', |
| 1278 | + array( 'ar_user_text' => $user->getName() ), |
| 1279 | + __METHOD__, |
| 1280 | + array( 'USE INDEX' => 'usertext_timestamp', 'LIMIT' => $minDiff ) ); |
| 1281 | + $deletedEdits = $dbr->numRows( $res ); |
1307 | 1282 | } |
| 1283 | + # Check to see if the user made almost all their edits at |
| 1284 | + # the last minute and delay promotion if that is the case. |
| 1285 | + if ( $wgFlaggedRevsAutopromote['excludeLastDays'] > 0 ) { |
| 1286 | + $cutoff_unixtime = time() - 86400*$wgFlaggedRevsAutopromote['excludeLastDays']; |
| 1287 | + $encCutoff = $dbr->addQuotes( $dbr->timestamp( $cutoff_unixtime ) ); |
| 1288 | + $res = $dbr->select( 'revision', '1', |
| 1289 | + array( 'rev_user' => $user->getId(), "rev_timestamp > $encCutoff" ), |
| 1290 | + __METHOD__, |
| 1291 | + array( 'USE INDEX' => 'user_timestamp', 'LIMIT' => $minDiff ) |
| 1292 | + ); |
| 1293 | + $recentEdits = $dbr->numRows( $res ); |
| 1294 | + } |
| 1295 | + # Are too many edits deleted or too recent to count? |
| 1296 | + if ( ( $deletedEdits + $recentEdits ) >= $minDiff ) { |
| 1297 | + return true; |
| 1298 | + } |
1308 | 1299 | # Check implicitly checked edits |
1309 | 1300 | if ( $totalCheckedEditsNeeded && $wgFlaggedRevsAutopromote['totalCheckedEdits'] ) { |
1310 | | - $dbr = isset( $dbr ) ? $dbr : wfGetDB( DB_SLAVE ); |
1311 | 1301 | $res = $dbr->select( array( 'revision', 'flaggedpages' ), '1', |
1312 | 1302 | array( 'rev_user' => $user->getId(), |
1313 | 1303 | 'fp_page_id = rev_page', 'fp_stable >= rev_id' ), |