User: System block reasons shouldn't expand templates
authorBrad Jorsch <bjorsch@wikimedia.org>
Sat, 12 May 2018 12:03:04 +0000 (08:03 -0400)
committerBrad Jorsch <bjorsch@wikimedia.org>
Sat, 12 May 2018 12:13:39 +0000 (08:13 -0400)
The block reasons for "system" blocks shouldn't expand wikitext
templates immediately. That should be left for the code parsing the
block reason for display.

This should only affect how these blocks are reported to API clients, as
when the block is displayed in the web UI it's passed through the parser
anyway. The main drawback, as far as the default messages go, is that
MediaWiki:sorbsreason won't have {{SITENAME}} expanded in
the API response anymore.

Bug: T191939
Change-Id: Ib2024721ea0e26358b9b50efdac16316d6d0f0b6

includes/user/User.php

index e235c18..7189bea 100644 (file)
@@ -1813,14 +1813,14 @@ class User implements IDBAccessObject, UserIdentity {
                        if ( self::isLocallyBlockedProxy( $ip ) ) {
                                $block = new Block( [
                                        'byText' => wfMessage( 'proxyblocker' )->text(),
-                                       'reason' => wfMessage( 'proxyblockreason' )->text(),
+                                       'reason' => wfMessage( 'proxyblockreason' )->plain(),
                                        'address' => $ip,
                                        'systemBlock' => 'proxy',
                                ] );
                        } elseif ( $this->isAnon() && $this->isDnsBlacklisted( $ip ) ) {
                                $block = new Block( [
                                        'byText' => wfMessage( 'sorbs' )->text(),
-                                       'reason' => wfMessage( 'sorbsreason' )->text(),
+                                       'reason' => wfMessage( 'sorbsreason' )->plain(),
                                        'address' => $ip,
                                        'systemBlock' => 'dnsbl',
                                ] );
@@ -1841,7 +1841,7 @@ class User implements IDBAccessObject, UserIdentity {
                        if ( $block instanceof Block ) {
                                # Mangle the reason to alert the user that the block
                                # originated from matching the X-Forwarded-For header.
-                               $block->mReason = wfMessage( 'xffblockreason', $block->mReason )->text();
+                               $block->mReason = wfMessage( 'xffblockreason', $block->mReason )->plain();
                        }
                }
 
@@ -1853,7 +1853,7 @@ class User implements IDBAccessObject, UserIdentity {
                        $block = new Block( [
                                'address' => $ip,
                                'byText' => 'MediaWiki default',
-                               'reason' => wfMessage( 'softblockrangesreason', $ip )->text(),
+                               'reason' => wfMessage( 'softblockrangesreason', $ip )->plain(),
                                'anonOnly' => true,
                                'systemBlock' => 'wgSoftBlockRanges',
                        ] );