Deprecate `$wgSysopEmailBans`
authorDannyS712 <DannyS712.enwiki@gmail.com>
Thu, 5 Sep 2019 22:57:06 +0000 (22:57 +0000)
committerMobrovac <mobrovac@wikimedia.org>
Tue, 17 Sep 2019 08:23:04 +0000 (08:23 +0000)
Bug: T232169
Change-Id: Iba2493eb2f49d32c5aa1b4da53c9c221847fb125

RELEASE-NOTES-1.34
includes/DefaultSettings.php
includes/Setup.php
includes/specials/SpecialBlock.php
tests/phpunit/includes/api/ApiBlockTest.php

index c4bbd4a..09f5346 100644 (file)
@@ -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 ===
 * …
index 6b04070..c3a37f3 100644 (file)
@@ -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;
 
index 518531a..6838c37 100644 (file)
@@ -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 );
 }
index 1b0db73..a03455b 100644 (file)
@@ -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' ) );
        }
index 2d19d38..fe6fcfc 100644 (file)
@@ -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,