From 28356eaabf8a3179e9115c0841b6cfa8c39927fd Mon Sep 17 00:00:00 2001
From: Daimona Eaytoy <daimona.wiki@gmail.com>
Date: Sun, 3 Jan 2021 16:19:52 +0100
Subject: [PATCH] SECURITY: Avoid deleted usernames leak in
 page_recent_contributors

Bug: T71367
Change-Id: I25e7e3ef11b7733f1f810e7342f684434f7e32c9
---
 includes/Variables/LazyVariableComputer.php | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/includes/Variables/LazyVariableComputer.php b/includes/Variables/LazyVariableComputer.php
index 85209a94..3fa940bc 100644
--- a/includes/Variables/LazyVariableComputer.php
+++ b/includes/Variables/LazyVariableComputer.php
@@ -305,6 +305,7 @@ class LazyVariableComputer {
 				$title = $this->titleFactory->makeTitle( $parameters['namespace'], $parameters['title'] );
 				$revision = $this->revisionLookup->getFirstRevision( $title );
 				if ( $revision ) {
+					// TODO T233241
 					$user = $revision->getUser();
 					$result = $user === null ? '' : $user->getName();
 				} else {
@@ -455,7 +456,12 @@ class LazyVariableComputer {
 				$revAuthors = $dbr->selectFieldValues(
 					$revQuery['tables'],
 					$revQuery['fields']['rev_user_text'],
-					[ 'rev_page' => $title->getArticleID() ],
+					[
+						'rev_page' => $title->getArticleID(),
+						// TODO Should deleted names be counted in the 10 authors? If yes, this check should
+						// be moved inside the foreach
+						'rev_deleted' => 0
+					],
 					$fname,
 					// Some pages have < 10 authors but many revisions (e.g. bot pages)
 					[ 'ORDER BY' => 'rev_timestamp DESC, rev_id DESC',
