From 387f936c134ded47bdeb72aab46d8bbc4ce272ad Mon Sep 17 00:00:00 2001
From: STran <stran@wikimedia.org>
Date: Fri, 19 Dec 2025 00:01:01 -0800
Subject: [PATCH] SECURTIY: Only show temp accounts on IP if temp accounts are
 known

Why:
The function will fail fatally otherwise as it cannot count an unknown thing

What:
- Check `isKnown` before proceeding with shouldShowCountFromThisIP

Bug: T413139
Change-Id: I0cc87247ad08f7aebfde40924fffc49aeb902afc
---
 .../SpecialContributionsBeforeMainOutputHandler.php         | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/src/HookHandler/SpecialContributionsBeforeMainOutputHandler.php b/src/HookHandler/SpecialContributionsBeforeMainOutputHandler.php
index 8da632f7..203eaed6 100644
--- a/src/HookHandler/SpecialContributionsBeforeMainOutputHandler.php
+++ b/src/HookHandler/SpecialContributionsBeforeMainOutputHandler.php
@@ -56,7 +56,11 @@ class SpecialContributionsBeforeMainOutputHandler implements SpecialContribution
 	}
 
 	private function shouldShowCountFromThisIP( UserIdentity $user, ContributionsSpecialPage $sp ): bool {
-		if ( $user->isRegistered() || !$this->isValidIPOrQueryableRange( $user->getName(), $sp->getConfig() ) ) {
+		if (
+			!$this->tempUserConfig->isKnown() ||
+			$user->isRegistered() ||
+			!$this->isValidIPOrQueryableRange( $user->getName(), $sp->getConfig() )
+		) {
 			return false;
 		}
 
-- 
2.48.1

