mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/AbuseFilter.git
synced 2024-11-27 23:40:19 +00:00
ViewRevert: avoid needless query
The previous code would call getUserGroups again once creating the log entry, but this was slightly flawed: we're updating groups on master, but the read happens on a replica that might be outdated, hence resulting in broken logging. Instead of reading from master, we can just keep a list of the groups that were actually added, and use that afterwards. Change-Id: I7cc282e15561de3a3d3e183808a65991aa27d2bb
This commit is contained in:
parent
8fe9902af3
commit
6c9fc516aa
|
@ -323,14 +323,16 @@ class AbuseFilterViewRevert extends AbuseFilterView {
|
|||
$user = User::newFromId( $result['userid'] );
|
||||
$currentGroups = $userGroupsManager->getUserGroups( $user );
|
||||
|
||||
$done = false;
|
||||
$addedGroups = [];
|
||||
foreach ( $removedGroups as $group ) {
|
||||
// TODO An addUserToGroups method with bulk updates would be nice
|
||||
$done = $userGroupsManager->addUserToGroup( $user, $group ) || $done;
|
||||
if ( $userGroupsManager->addUserToGroup( $user, $group ) ) {
|
||||
$addedGroups[] = $group;
|
||||
}
|
||||
}
|
||||
|
||||
// Don't log if no groups were added.
|
||||
if ( !$done ) {
|
||||
if ( !$addedGroups ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -347,7 +349,7 @@ class AbuseFilterViewRevert extends AbuseFilterView {
|
|||
);
|
||||
$logEntry->setParameters( [
|
||||
'4::oldgroups' => $currentGroups,
|
||||
'5::newgroups' => $userGroupsManager->getUserGroups( $user )
|
||||
'5::newgroups' => array_merge( $currentGroups, $addedGroups )
|
||||
] );
|
||||
$logEntry->publish( $logEntry->insert() );
|
||||
|
||||
|
|
Loading…
Reference in a new issue