From 527ba1ab2b5b6b268513ec7d16b635e24b503e10 Mon Sep 17 00:00:00 2001
From: dreamyjazz <dreamyjazzwikipedia@gmail.com>
Date: Tue, 20 Sep 2022 15:50:27 +0100
Subject: [PATCH] Do not show suppressed usernames on edits in the API

Ensure that the check for what a user can see also includes whether
the user can see the username for the edit.

Bug: T318166
---
 src/Api/ApiQueryCheckUser.php | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/src/Api/ApiQueryCheckUser.php b/src/Api/ApiQueryCheckUser.php
index a61a8cc3..78712f34 100644
--- a/src/Api/ApiQueryCheckUser.php
+++ b/src/Api/ApiQueryCheckUser.php
@@ -213,6 +213,13 @@ class ApiQueryCheckUser extends ApiQueryBase {
 							) ) {
 								$edit['summary'] = $this->msg( 'rev-deleted-comment' )->text();
 							}
+							if ( !RevisionRecord::userCanBitfield(
+								$revRecord->getVisibility(),
+								RevisionRecord::DELETED_USER,
+								$this->getUser()
+							) ) {
+								$edit['user'] = $this->msg( 'rev-deleted-user' )->text();
+							}
 						}
 					}
 					if ( $row->cuc_minor ) {
-- 
2.25.1

