Skip to content

Commit

Permalink
Standardise IP display formatting across extension
Browse files Browse the repository at this point in the history
Bug: T351945
Change-Id: I14c50457caa04b5c4718a60256bcbc6117993ee1
  • Loading branch information
DatGuy1 authored and TehKittyCat committed Apr 20, 2024
1 parent 7e512b7 commit e2d8a07
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/CheckUser/Pagers/CheckUserGetIPsPager.php
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ public function __construct(
/** @inheritDoc */
public function formatRow( $row ): string {
$lang = $this->getLanguage();
$ip = $row->ip;
$ip = IPUtils::prettifyIP( $row->ip );
$templateParams = [];
$templateParams['ipLink'] = $this->getSelfLink( $ip,
[
Expand Down
9 changes: 5 additions & 4 deletions src/CheckUser/Pagers/CheckUserGetUsersPager.php
Original file line number Diff line number Diff line change
Expand Up @@ -217,8 +217,7 @@ public function formatUserRow( string $user_text ): string {
// don't render parentheses in HTML markup (CSS will provide)
false
);
$ip = IPUtils::isIPAddress( $user ) ? $user : '';
if ( $ip ) {
if ( $userIsIP ) {
$templateParams['userLinks'] = $this->msg( 'checkuser-userlinks-ip', $user )->parse();
} elseif ( !$userNonExistent ) {
if ( $this->msg( 'checkuser-userlinks' )->exists() ) {
Expand All @@ -229,7 +228,7 @@ public function formatUserRow( string $user_text ): string {
// Add global user tools links
// Add CentralAuth link for real registered users
if ( $this->centralAuthToollink !== false
&& !IPUtils::isIPAddress( $user_text )
&& !$userIsIP
&& !$userNonExistent
) {
// Get CentralAuth SpecialPage name in UserLang from the first Alias name
Expand Down Expand Up @@ -416,9 +415,11 @@ protected function preprocessResults( $result ) {
}
$this->userSets['edits'][$row->user_text]++;
$this->userSets['first'][$row->user_text] = $row->timestamp;
// Prettify IP
$formattedIP = IPUtils::prettifyIP( $row->ip ) ?? $row->ip;
// Treat blank or NULL xffs as empty strings
$xff = empty( $row->xff ) ? null : $row->xff;
$xff_ip_combo = [ $row->ip, $xff ];
$xff_ip_combo = [ $formattedIP, $xff ];
// Add this IP/XFF combo for this username if it's not already there
if ( !in_array( $xff_ip_combo, $this->userSets['infosets'][$row->user_text] ) ) {
$this->userSets['infosets'][$row->user_text][] = $xff_ip_combo;
Expand Down

0 comments on commit e2d8a07

Please sign in to comment.