r78255 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r78254‎ | r78255 | r78256 >
Date:16:12, 12 December 2010
Author:aaron
Status:deferred
Tags:
Comment:
* Added 'excludeLastDays' param to make it harder to pile on edits at the last minute to get promoted. There should be time for people to check if it's vandalism.
* Removed 'recentContentEdits', which is pretty redundant and unnecessary.
* Actually check the right value in computing $minDiff (wtf).
* Made 'excludeDeleted' avoid using estimates (which may as well be random).
* Removed $dbr pseudo-optimization crap.
Modified paths:
  • /trunk/extensions/FlaggedRevs/FlaggedRevs.hooks.php (modified) (history)
  • /trunk/extensions/FlaggedRevs/FlaggedRevs.php (modified) (history)

Diff [purge]

Index: trunk/extensions/FlaggedRevs/FlaggedRevs.php
@@ -145,10 +145,10 @@
146146 'days' => 60, # days since registration
147147 'edits' => 250, # total edit count
148148 'excludeDeleted' => true, # exclude deleted edits from 'edits' count above?
 149+ 'excludeLastDays' => 1, # exclude last X days of edits from 'edits' count above
149150 // Require 'benchmark' edits 'spacing' days apart from each other
150151 'spacing' => 3, # spacing of edit intervals
151152 'benchmarks' => 15, # how many edit intervals are needed?
152 - 'recentContentEdits' => 0, # $wgContentNamespaces edits in recent changes
153153 // Either totalContentEdits reqs OR totalCheckedEdits requirements needed
154154 'totalContentEdits' => 300, # $wgContentNamespaces edits OR...
155155 'totalCheckedEdits' => 200, # ...Edits before the stable version of pages
Index: trunk/extensions/FlaggedRevs/FlaggedRevs.hooks.php
@@ -1227,12 +1227,12 @@
12281228 return true;
12291229 }
12301230 }
 1231+ $dbr = wfGetDB( DB_SLAVE );
12311232 # See if the page actually has sufficient content...
12321233 if ( $wgFlaggedRevsAutopromote['userpageBytes'] > 0 ) {
12331234 if ( !$user->getUserPage()->exists() ) {
12341235 return true;
12351236 }
1236 - $dbr = isset( $dbr ) ? $dbr : wfGetDB( DB_SLAVE );
12371237 $size = $dbr->selectField( 'page', 'page_len',
12381238 array( 'page_namespace' => $user->getUserPage()->getNamespace(),
12391239 'page_title' => $user->getUserPage()->getDBkey() ),
@@ -1265,48 +1265,38 @@
12661266 }
12671267 }
12681268 }
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;
12851272 # Check to see if the user has so many deleted edits that
12861273 # they don't actually enough live edits. This is because
12871274 # $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 );
13071282 }
 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+ }
13081299 # Check implicitly checked edits
13091300 if ( $totalCheckedEditsNeeded && $wgFlaggedRevsAutopromote['totalCheckedEdits'] ) {
1310 - $dbr = isset( $dbr ) ? $dbr : wfGetDB( DB_SLAVE );
13111301 $res = $dbr->select( array( 'revision', 'flaggedpages' ), '1',
13121302 array( 'rev_user' => $user->getId(),
13131303 'fp_page_id = rev_page', 'fp_stable >= rev_id' ),

Status & tagging log