RightsLogFormatter: Use DB key to generate foreign user link
authorAlex Monk <krenair@gmail.com>
Fri, 25 Mar 2016 04:17:47 +0000 (04:17 +0000)
committerAlex Monk <krenair@gmail.com>
Sat, 26 Mar 2016 13:59:44 +0000 (13:59 +0000)
getText returns a version of the title with spaces instead of underscores,
which confuses WikiMap

Also show underscore in text displayed to user

Bug: T130835
Change-Id: I192e28062590e4602127f895b88328b52018b468

includes/logging/RightsLogFormatter.php

index b9dfb6c..1fd4b7f 100644 (file)
@@ -33,12 +33,19 @@ class RightsLogFormatter extends LogFormatter {
                global $wgContLang, $wgUserrightsInterwikiDelimiter;
 
                if ( !$this->plaintext ) {
-                       $text = $wgContLang->ucfirst( $title->getText() );
+                       $text = $wgContLang->ucfirst( $title->getDBkey() );
                        $parts = explode( $wgUserrightsInterwikiDelimiter, $text, 2 );
 
                        if ( count( $parts ) === 2 ) {
-                               $titleLink = WikiMap::foreignUserLink( $parts[1], $parts[0],
-                                       htmlspecialchars( $title->getText() ) );
+                               $titleLink = WikiMap::foreignUserLink(
+                                       $parts[1],
+                                       $parts[0],
+                                       htmlspecialchars(
+                                               strtr( $parts[0], '_', ' ' ) .
+                                               $wgUserrightsInterwikiDelimiter .
+                                               $parts[1]
+                                       )
+                               );
 
                                if ( $titleLink !== false ) {
                                        return $titleLink;