From 3a2c7d1b5d4815730db68429a164682aa6bfcc73 Mon Sep 17 00:00:00 2001 From: DannyS712 Date: Thu, 5 Sep 2019 22:57:06 +0000 Subject: [PATCH] Deprecate `$wgSysopEmailBans` Bug: T232169 Change-Id: Iba2493eb2f49d32c5aa1b4da53c9c221847fb125 --- RELEASE-NOTES-1.34 | 3 +++ includes/DefaultSettings.php | 2 ++ includes/Setup.php | 7 +++++++ includes/specials/SpecialBlock.php | 4 ++-- tests/phpunit/includes/api/ApiBlockTest.php | 2 -- 5 files changed, 14 insertions(+), 4 deletions(-) diff --git a/RELEASE-NOTES-1.34 b/RELEASE-NOTES-1.34 index c4bbd4af94..09f5346933 100644 --- a/RELEASE-NOTES-1.34 +++ b/RELEASE-NOTES-1.34 @@ -572,6 +572,9 @@ because of Phabricator reports. * StreamFile::send404Message() and StreamFile::parseRange() are now deprecated. Use HTTPFileStreamer::send404Message() and HTTPFileStreamer::parseRange() respectively instead. +* Global variable $wgSysopEmailBans is deprecated; to allow sysops to ban + users from sending emails, use + $wgGroupPermissions['sysop']['blockemail'] = true; === Other changes in 1.34 === * … diff --git a/includes/DefaultSettings.php b/includes/DefaultSettings.php index 6b04070fdb..c3a37f33e2 100644 --- a/includes/DefaultSettings.php +++ b/includes/DefaultSettings.php @@ -4991,6 +4991,8 @@ $wgBlockAllowsUTEdit = true; /** * Allow sysops to ban users from accessing Emailuser + * @deprecated since 1.34; `$wgGroupPermissions['sysop']['blockemail'] = true;` + * should be used instead */ $wgSysopEmailBans = true; diff --git a/includes/Setup.php b/includes/Setup.php index 518531aacf..6838c37260 100644 --- a/includes/Setup.php +++ b/includes/Setup.php @@ -440,6 +440,13 @@ if ( $wgEnableEmail ) { $wgUsersNotifiedOnAllChanges = []; } +// $wgSysopEmailBans deprecated in 1.34 +if ( isset( $wgSysopEmailBans ) && $wgSysopEmailBans === false ) { + foreach ( $wgGroupPermissions as $group => $_ ) { + unset( $wgGroupPermissions[$group]['blockemail'] ); + } +} + if ( $wgMetaNamespace === false ) { $wgMetaNamespace = str_replace( ' ', '_', $wgSitename ); } diff --git a/includes/specials/SpecialBlock.php b/includes/specials/SpecialBlock.php index 1b0db7345c..a03455bbe6 100644 --- a/includes/specials/SpecialBlock.php +++ b/includes/specials/SpecialBlock.php @@ -1124,9 +1124,9 @@ class SpecialBlock extends FormSpecialPage { * @return bool */ public static function canBlockEmail( UserIdentity $user ) { - global $wgEnableUserEmail, $wgSysopEmailBans; + global $wgEnableUserEmail; - return ( $wgEnableUserEmail && $wgSysopEmailBans && MediaWikiServices::getInstance() + return ( $wgEnableUserEmail && MediaWikiServices::getInstance() ->getPermissionManager() ->userHasRight( $user, 'blockemail' ) ); } diff --git a/tests/phpunit/includes/api/ApiBlockTest.php b/tests/phpunit/includes/api/ApiBlockTest.php index 2d19d3817b..fe6fcfcca8 100644 --- a/tests/phpunit/includes/api/ApiBlockTest.php +++ b/tests/phpunit/includes/api/ApiBlockTest.php @@ -182,7 +182,6 @@ class ApiBlockTest extends ApiTestCase { $this->setMwGlobals( [ 'wgEnableEmail' => true, 'wgEnableUserEmail' => true, - 'wgSysopEmailBans' => true, ] ); $res = $this->doBlock( [ 'noemail' => '' ] ); @@ -200,7 +199,6 @@ class ApiBlockTest extends ApiTestCase { $this->setMwGlobals( [ 'wgEnableEmail' => true, 'wgEnableUserEmail' => true, - 'wgSysopEmailBans' => true, ] ); $this->setExpectedException( ApiUsageException::class, -- 2.20.1