}
// Purge old, expired memberships from the DB
- JobQueueGroup::singleton()->push( new UserGroupExpiryJob() );
+ $hasExpiredRow = $dbw->selectField(
+ 'user_groups',
+ '1',
+ [ 'ug_expiry < ' . $dbw->addQuotes( $dbw->timestamp() ) ],
+ __METHOD__
+ );
+ if ( $hasExpiredRow ) {
+ JobQueueGroup::singleton()->lazyPush( new UserGroupExpiryJob() );
+ }
// Check that the values make sense
if ( $this->group === null ) {
$ticket = $lbFactory->getEmptyTransactionTicket( __METHOD__ );
$dbw = $services->getDBLoadBalancer()->getConnection( DB_MASTER );
- $lockKey = $dbw->getDomainID() . ':usergroups-prune'; // specific to this wiki
+ $lockKey = "{$dbw->getDomainID()}:UserGroupMembership:purge"; // per-wiki
$scopedLock = $dbw->getScopedLockAndFlush( $lockKey, __METHOD__, 0 );
if ( !$scopedLock ) {
return false; // already running