From d152ff76a562c536b2088bae9ef4da83332d1a21 Mon Sep 17 00:00:00 2001 From: Brad Jorsch Date: Sat, 12 May 2018 08:03:04 -0400 Subject: [PATCH] User: System block reasons shouldn't expand templates 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 | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/includes/user/User.php b/includes/user/User.php index e235c18928..7189bea120 100644 --- a/includes/user/User.php +++ b/includes/user/User.php @@ -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', ] ); -- 2.20.1