From f516eaefb65a88c5d0f16d1f7a3fe8aaf8597ef8 Mon Sep 17 00:00:00 2001 From: Happy-melon Date: Sat, 12 Mar 2011 12:13:22 +0000 Subject: [PATCH] Deprecate $wgSysopUserBans and $wgSysopRangeBans, both of which are pre-1.2, and totally antiquated. Can't think of any reason why a modern wiki might want to make blocks IP-only; syadmins can still disable rangeblocks by setting $wgBlockCIDRLimit to the maximum for each IP mode (32 for IP4, 128 for IP6). --- includes/DefaultSettings.php | 10 +++++-- includes/Linker.php | 4 +-- includes/specials/SpecialBlockip.php | 30 +++++++------------ includes/specials/SpecialContributions.php | 3 +- .../specials/SpecialDeletedContributions.php | 4 +-- includes/specials/SpecialIpblocklist.php | 6 ++-- 6 files changed, 27 insertions(+), 30 deletions(-) diff --git a/includes/DefaultSettings.php b/includes/DefaultSettings.php index 889fa99b5c..70f3a3be40 100644 --- a/includes/DefaultSettings.php +++ b/includes/DefaultSettings.php @@ -3175,10 +3175,16 @@ $wgSecureLogin = false; * @{ */ -/** Allow sysops to ban logged-in users */ +/** + * Allow sysops to ban logged-in users + * @deprecated @since 1.18 + */ $wgSysopUserBans = true; -/** Allow sysops to ban IP ranges */ +/** + * Allow sysops to ban IP ranges + * @deprecated @since 1.18; set $wgBlockCIDRLimit to array( 'IPv4' => 32, 'IPv6 => 128 ) instead. + */ $wgSysopRangeBans = true; /** diff --git a/includes/Linker.php b/includes/Linker.php index 5a499cd021..a2438e71ef 100644 --- a/includes/Linker.php +++ b/includes/Linker.php @@ -880,9 +880,9 @@ class Linker { * @return String: HTML fragment */ public function userToolLinks( $userId, $userText, $redContribsWhenNoEdits = false, $flags = 0, $edits = null ) { - global $wgUser, $wgDisableAnonTalk, $wgSysopUserBans, $wgLang; + global $wgUser, $wgDisableAnonTalk, $wgLang; $talkable = !( $wgDisableAnonTalk && 0 == $userId ); - $blockable = ( $wgSysopUserBans || 0 == $userId ) && !$flags & self::TOOL_LINKS_NOBLOCK; + $blockable = !$flags & self::TOOL_LINKS_NOBLOCK; $items = array(); if ( $talkable ) { diff --git a/includes/specials/SpecialBlockip.php b/includes/specials/SpecialBlockip.php index 9b11a5c0aa..6f4736e080 100644 --- a/includes/specials/SpecialBlockip.php +++ b/includes/specials/SpecialBlockip.php @@ -106,16 +106,12 @@ class IPBlockForm extends SpecialPage { } public function showForm( $err ) { - global $wgOut, $wgUser, $wgSysopUserBans; + global $wgOut, $wgUser; $wgOut->setPageTitle( wfMsg( 'blockip-title' ) ); $wgOut->addWikiMsg( 'blockiptext' ); - if( $wgSysopUserBans ) { - $mIpaddress = Xml::label( wfMsg( 'ipadressorusername' ), 'mw-bi-target' ); - } else { - $mIpaddress = Xml::label( wfMsg( 'ipaddress' ), 'mw-bi-target' ); - } + $mIpaddress = Xml::label( wfMsg( 'ipadressorusername' ), 'mw-bi-target' ); $mIpbexpiry = Xml::label( wfMsg( 'ipbexpiry' ), 'wpBlockExpiry' ); $mIpbother = Xml::label( wfMsg( 'ipbother' ), 'mw-bi-other' ); $mIpbreasonother = Xml::label( wfMsg( 'ipbreason' ), 'wpBlockReasonList' ); @@ -426,7 +422,7 @@ class IPBlockForm extends SpecialPage { * @return array(message key, arguments) on failure, empty array on success */ function doBlock( &$userId = null, &$expiry = null ) { - global $wgUser, $wgSysopUserBans, $wgSysopRangeBans, $wgBlockAllowsUTEdit, $wgBlockCIDRLimit; + global $wgUser, $wgBlockAllowsUTEdit, $wgBlockCIDRLimit; $userId = 0; # Expand valid IPv6 addresses, usernames are left as is @@ -441,7 +437,7 @@ class IPBlockForm extends SpecialPage { $matches = array(); if( preg_match( "/^($rxIP4)\\/(\\d{1,2})$/", $this->BlockAddress, $matches ) ) { # IPv4 - if( $wgSysopRangeBans ) { + if( $wgBlockCIDRLimit['IPv4'] != 32 ){ if( !IP::isIPv4( $this->BlockAddress ) || $matches[2] > 32 ) { return array( 'ip_range_invalid' ); } elseif ( $matches[2] < $wgBlockCIDRLimit['IPv4'] ) { @@ -454,7 +450,7 @@ class IPBlockForm extends SpecialPage { } } elseif( preg_match( "/^($rxIP6)\\/(\\d{1,3})$/", $this->BlockAddress, $matches ) ) { # IPv6 - if( $wgSysopRangeBans ) { + if( $wgBlockCIDRLimit['IPv6'] != 128 ) { if( !IP::isIPv6( $this->BlockAddress ) || $matches[2] > 128 ) { return array( 'ip_range_invalid' ); } elseif( $matches[2] < $wgBlockCIDRLimit['IPv6'] ) { @@ -467,17 +463,13 @@ class IPBlockForm extends SpecialPage { } } else { # Username block - if( $wgSysopUserBans ) { - $user = User::newFromName( $this->BlockAddress ); - if( $user instanceof User && $user->getId() ) { - # Use canonical name - $userId = $user->getId(); - $this->BlockAddress = $user->getName(); - } else { - return array( 'nosuchusershort', htmlspecialchars( $user ? $user->getName() : $this->BlockAddress ) ); - } + $user = User::newFromName( $this->BlockAddress ); + if( $user instanceof User && $user->getId() ) { + # Use canonical name + $userId = $user->getId(); + $this->BlockAddress = $user->getName(); } else { - return array( 'badipaddress' ); + return array( 'nosuchusershort', htmlspecialchars( $user ? $user->getName() : $this->BlockAddress ) ); } } } diff --git a/includes/specials/SpecialContributions.php b/includes/specials/SpecialContributions.php index 6e2f36ec91..d4fb9452f2 100644 --- a/includes/specials/SpecialContributions.php +++ b/includes/specials/SpecialContributions.php @@ -240,7 +240,6 @@ class SpecialContributions extends SpecialPage { * @param $subject User: The viewing user ($wgUser is still checked in some cases, like userrights page!!) */ public static function getUserLinks( Title $userpage, Title $talkpage, User $target, User $subject ) { - global $wgSysopUserBans; $sk = $subject->getSkin(); $id = $target->getId(); @@ -248,7 +247,7 @@ class SpecialContributions extends SpecialPage { $tools[] = $sk->link( $talkpage, wfMsgHtml( 'sp-contributions-talk' ) ); - if( ( $id !== null && $wgSysopUserBans ) || ( $id === null && IP::isIPAddress( $username ) ) ) { + if( ( $id !== null ) || ( $id === null && IP::isIPAddress( $username ) ) ) { if( $subject->isAllowed( 'block' ) ) { # Block / Change block / Unblock links if ( $target->isBlocked() ) { $tools[] = $sk->linkKnown( # Change block link diff --git a/includes/specials/SpecialDeletedContributions.php b/includes/specials/SpecialDeletedContributions.php index bc2a90b309..6041e3c0ff 100644 --- a/includes/specials/SpecialDeletedContributions.php +++ b/includes/specials/SpecialDeletedContributions.php @@ -354,7 +354,7 @@ class DeletedContributionsPage extends SpecialPage { * @todo Fixme: almost the same as contributionsSub in SpecialContributions.php. Could be combined. */ function getSubTitle( $nt, $id ) { - global $wgSysopUserBans, $wgLang, $wgUser, $wgOut; + global $wgLang, $wgUser, $wgOut; $sk = $wgUser->getSkin(); @@ -368,7 +368,7 @@ class DeletedContributionsPage extends SpecialPage { if( $talk ) { # Talk page link $tools[] = $sk->link( $talk, wfMsgHtml( 'sp-contributions-talk' ) ); - if( ( $id !== null && $wgSysopUserBans ) || ( $id === null && IP::isIPAddress( $nt->getText() ) ) ) { + if( ( $id !== null ) || ( $id === null && IP::isIPAddress( $nt->getText() ) ) ) { if( $wgUser->isAllowed( 'block' ) ) { # Block / Change block / Unblock links if ( $userObj->isBlocked() ) { $tools[] = $sk->linkKnown( # Change block link diff --git a/includes/specials/SpecialIpblocklist.php b/includes/specials/SpecialIpblocklist.php index d7c6f3295f..764cddc3df 100644 --- a/includes/specials/SpecialIpblocklist.php +++ b/includes/specials/SpecialIpblocklist.php @@ -121,7 +121,7 @@ class IPUnblockForm extends SpecialPage { * @return $out string: HTML form */ function showForm( $err = null ) { - global $wgOut, $wgUser, $wgSysopUserBans; + global $wgOut, $wgUser; $wgOut->addWikiMsg( 'unblockiptext' ); @@ -139,12 +139,12 @@ class IPUnblockForm extends SpecialPage { $encName = htmlspecialchars( $block->getRedactedName() ); $encId = $this->id; $addressPart = $encName . Html::hidden( 'id', $encId ); - $ipa = wfMsgHtml( $wgSysopUserBans ? 'ipadressorusername' : 'ipaddress' ); + $ipa = wfMsgHtml( 'ipadressorusername' ); } } if ( !$addressPart ) { $addressPart = Xml::input( 'wpUnblockAddress', 40, $this->ip, array( 'type' => 'text', 'tabindex' => '1' ) ); - $ipa = Xml::label( wfMsg( $wgSysopUserBans ? 'ipadressorusername' : 'ipaddress' ), 'wpUnblockAddress' ); + $ipa = Xml::label( wfMsg( 'ipadressorusername' ), 'wpUnblockAddress' ); } $wgOut->addHTML( -- 2.20.1