+
+ // Clear cache for the affected users (bug 40340)
+ if ( $affected > 0 ) {
+ // XXX: This also invalidates cache of unaffected users that
+ // were in the new group and not in the group.
+ $res = $dbw->select( 'user_groups', 'ug_user',
+ array( 'ug_group' => $newGroup,
+ "ug_user BETWEEN $blockStart AND $blockEnd" ),
+ __METHOD__
+ );
+ if ( $res !== false ) {
+ foreach ( $res as $row ) {
+ $user = User::newFromId( $row->ug_user );
+ $user->invalidateCache();
+ }
+ }
+ }
+
+ $count += $affected;