$lockKey = wfWikiID() . ':recentchanges-prune';
$dbw = wfGetDB( DB_MASTER );
- if ( !$dbw->lockIsFree( $lockKey, __METHOD__ )
- || !$dbw->lock( $lockKey, __METHOD__, 1 )
- ) {
- return; // already in progress
+ if ( !$dbw->lock( $lockKey, __METHOD__, 0 ) ) {
+ // already in progress
+ return;
}
$factory = MediaWikiServices::getInstance()->getDBLoadBalancerFactory();
$ticket = $factory->getEmptyTransactionTicket( __METHOD__ );
$cutoff = $dbw->timestamp( time() - $wgRCMaxAge );
+ $rcQuery = RecentChange::getQueryInfo();
do {
$rcIds = [];
$rows = [];
- $res = $dbw->select( 'recentchanges',
- RecentChange::selectFields(),
+ $res = $dbw->select(
+ $rcQuery['tables'],
+ $rcQuery['fields'],
[ 'rc_timestamp < ' . $dbw->addQuotes( $cutoff ) ],
__METHOD__,
- [ 'LIMIT' => $wgUpdateRowsPerQuery ]
+ [ 'LIMIT' => $wgUpdateRowsPerQuery ],
+ $rcQuery['joins']
);
foreach ( $res as $row ) {
$rcIds[] = $row->rc_id;
$dbw->setSessionOptions( [ 'connTimeout' => 900 ] );
$lockKey = wfWikiID() . '-activeusers';
- if ( !$dbw->lockIsFree( $lockKey, __METHOD__ ) || !$dbw->lock( $lockKey, __METHOD__, 1 ) ) {
+ if ( !$dbw->lock( $lockKey, __METHOD__, 0 ) ) {
// Exclusive update (avoids duplicate entries)… it's usually fine to just drop out here,
// if the Job is already running.
return;
$eTimestamp = min( $sTimestamp + $window, $nowUnix );
// Get all the users active since the last update
+ $actorQuery = ActorMigration::newMigration()->getJoin( 'rc_user' );
$res = $dbw->select(
- [ 'recentchanges' ],
- [ 'rc_user_text', 'lastedittime' => 'MAX(rc_timestamp)' ],
+ [ 'recentchanges' ] + $actorQuery['tables'],
[
- 'rc_user > 0', // actual accounts
+ 'rc_user_text' => $actorQuery['fields']['rc_user_text'],
+ 'lastedittime' => 'MAX(rc_timestamp)'
+ ],
+ [
+ $actorQuery['fields']['rc_user'] . ' > 0', // actual accounts
'rc_type != ' . $dbw->addQuotes( RC_EXTERNAL ), // no wikidata
'rc_log_type IS NULL OR rc_log_type != ' . $dbw->addQuotes( 'newusers' ),
'rc_timestamp >= ' . $dbw->addQuotes( $dbw->timestamp( $sTimestamp ) ),
[
'GROUP BY' => [ 'rc_user_text' ],
'ORDER BY' => 'NULL' // avoid filesort
- ]
+ ],
+ $actorQuery['joins']
);
$names = [];
foreach ( $res as $row ) {