From: Aaron Schulz Date: Fri, 5 Jul 2019 23:27:43 +0000 (-0700) Subject: Optimize JobQueue utilization in UserGroupMembership::insert() X-Git-Tag: 1.34.0-rc.0~1050^2 X-Git-Url: https://git.cyclocoop.org/%7B%24admin_url%7Dmembres/cotisations/rappels.php?a=commitdiff_plain;h=9e8ad1a560ece73928d9d34605aabeb38d61b743;p=lhc%2Fweb%2Fwiklou.git Optimize JobQueue utilization in UserGroupMembership::insert() Change-Id: I20d6d753221616817150f34307a8ffaf1bb74ae8 --- diff --git a/includes/user/UserGroupMembership.php b/includes/user/UserGroupMembership.php index e06df9fd23..eb555672a2 100644 --- a/includes/user/UserGroupMembership.php +++ b/includes/user/UserGroupMembership.php @@ -159,7 +159,15 @@ class UserGroupMembership { } // 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 ) {