From f2de3967d9bd1658c460e8247fce43f74e19a325 Mon Sep 17 00:00:00 2001 From: Kunal Mehta Date: Sun, 23 Feb 2014 16:24:34 -0800 Subject: [PATCH] Add 'mw-anonuserlink' class for anonymous users Bug: 43179 Change-Id: I57780e1045044e8532dc6defc4cca2e27434c055 --- includes/Linker.php | 4 +++- tests/phpunit/includes/LinkerTest.php | 14 +++++++------- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/includes/Linker.php b/includes/Linker.php index 23bfd61cb0..b42d54c4c3 100644 --- a/includes/Linker.php +++ b/includes/Linker.php @@ -1068,11 +1068,13 @@ class Linker { * @since 1.19 Method exists for a long time. $altUserName was added in 1.19. */ public static function userLink( $userId, $userName, $altUserName = false ) { + $classes = 'mw-userlink'; if ( $userId == 0 ) { $page = SpecialPage::getTitleFor( 'Contributions', $userName ); if ( $altUserName === false ) { $altUserName = IP::prettifyIP( $userName ); } + $classes .= ' mw-anonuserlink'; // Separate link class for anons (bug 43179) } else { $page = Title::makeTitle( NS_USER, $userName ); } @@ -1080,7 +1082,7 @@ class Linker { return self::link( $page, htmlspecialchars( $altUserName !== false ? $altUserName : $userName ), - array( 'class' => 'mw-userlink' ) + array( 'class' => $classes ) ); } diff --git a/tests/phpunit/includes/LinkerTest.php b/tests/phpunit/includes/LinkerTest.php index b605f08f16..351ad34433 100644 --- a/tests/phpunit/includes/LinkerTest.php +++ b/tests/phpunit/includes/LinkerTest.php @@ -28,38 +28,38 @@ class LinkerTest extends MediaWikiLangTestCase { ### ANONYMOUS USER ######################################## array( - 'JohnDoe', + 'JohnDoe', 0, 'JohnDoe', false, ), array( - '::1', + '::1', 0, '::1', false, 'Anonymous with pretty IPv6' ), array( - '::1', + '::1', 0, '0:0:0:0:0:0:0:1', false, 'Anonymous with almost pretty IPv6' ), array( - '::1', + '::1', 0, '0000:0000:0000:0000:0000:0000:0000:0001', false, 'Anonymous with full IPv6' ), array( - 'AlternativeUsername', + 'AlternativeUsername', 0, '::1', 'AlternativeUsername', 'Anonymous with pretty IPv6 and an alternative username' ), # IPV4 array( - '127.0.0.1', + '127.0.0.1', 0, '127.0.0.1', false, 'Anonymous with IPv4' ), array( - 'AlternativeUsername', + 'AlternativeUsername', 0, '127.0.0.1', 'AlternativeUsername', 'Anonymous with IPv4 and an alternative username' ), -- 2.20.1