r60644 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r60643‎ | r60644 | r60645 >
Date:05:44, 5 January 2010
Author:overlordq
Status:ok (Comments)
Tags:
Comment:
Split rangeblock error message, allow configuring max size of IPv6 blocks as well. (r58377)
Modified paths:
  • /trunk/phase3/includes/DefaultSettings.php (modified) (history)
  • /trunk/phase3/includes/specials/SpecialBlockip.php (modified) (history)
  • /trunk/phase3/languages/messages/MessagesEn.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/DefaultSettings.php
@@ -1302,7 +1302,10 @@
13031303 $wgAutoblockExpiry = 86400; # Number of seconds before autoblock entries expire
13041304 $wgBlockAllowsUTEdit = false; # Default setting for option on block form to allow self talkpage editing whilst blocked
13051305 $wgSysopEmailBans = true; # Allow sysops to ban users from accessing Emailuser
1306 -$wgBlockCIDRLimit = 16; # Blocks larger than a /16 (64k addresses) will not be allowed
 1306+$wgBlockCIDRLimit = array(
 1307+ 'IPv4' => 16, # Blocks larger than a /16 (64k addresses) will not be allowed
 1308+ 'IPv6' => 64, # 2^64 = ~1.8x10^19 addresses
 1309+);
13071310
13081311 # Pages anonymous user may see as an array, e.g.:
13091312 # array ( "Main Page", "Wikipedia:Help");
Index: trunk/phase3/includes/specials/SpecialBlockip.php
@@ -383,8 +383,10 @@
384384 if( preg_match( "/^($rxIP4)\\/(\\d{1,2})$/", $this->BlockAddress, $matches ) ) {
385385 # IPv4
386386 if( $wgSysopRangeBans ) {
387 - if( !IP::isIPv4( $this->BlockAddress ) || $matches[2] < $wgBlockCIDRLimit || $matches[2] > 32 ) {
 387+ if( !IP::isIPv4( $this->BlockAddress ) || $matches[2] > 32 ) {
388388 return array( 'ip_range_invalid' );
 389+ } elseif ( $matches[2] < $wgBlockCIDRLimit['IPv4'] ) {
 390+ return array( 'ip_range_toolarge', $wgBlockCIDRLimit['IPv4'] );
389391 }
390392 $this->BlockAddress = Block::normaliseRange( $this->BlockAddress );
391393 } else {
@@ -394,8 +396,10 @@
395397 } elseif( preg_match( "/^($rxIP6)\\/(\\d{1,3})$/", $this->BlockAddress, $matches ) ) {
396398 # IPv6
397399 if( $wgSysopRangeBans ) {
398 - if( !IP::isIPv6( $this->BlockAddress ) || $matches[2] < 64 || $matches[2] > 128 ) {
 400+ if( !IP::isIPv6( $this->BlockAddress ) || $matches[2] > 128 ) {
399401 return array( 'ip_range_invalid' );
 402+ } elseif( $matches[2] < $wgBlockCIDRLimit['IPv6'] ) {
 403+ return array( 'ip_range_toolarge', $wgBlockCIDRLimit['IPv6'] );
400404 }
401405 $this->BlockAddress = Block::normaliseRange( $this->BlockAddress );
402406 } else {
Index: trunk/phase3/languages/messages/MessagesEn.php
@@ -2958,6 +2958,7 @@
29592959 'ipb_blocked_as_range' => 'Error: The IP address $1 is not blocked directly and cannot be unblocked.
29602960 It is, however, blocked as part of the range $2, which can be unblocked.',
29612961 'ip_range_invalid' => 'Invalid IP range.',
 2962+'ip_range_toolarge' => 'Range blocks larger than /$1 are not allowed.',
29622963 'blockme' => 'Block me',
29632964 'proxyblocker' => 'Proxy blocker',
29642965 'proxyblocker-disabled' => 'This function is disabled.',

Follow-up revisions

RevisionCommit summaryAuthorDate
r60645Add missing message (r60644)overlordq07:03, 5 January 2010

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r58377(bug 3340) Allow configuring of /16 limit on range blocksdemon21:41, 30 October 2009

Comments

#Comment by Simetrical (talk | contribs)   22:44, 10 January 2010

This looks incompatible with old $wgBlockCIDRLimit configs. You need some compatibility code here to initialize it properly if it's set to an integer instead of an array, preferably with a comment in DefaultSettings.php noting the old form so people don't get confused.

Also, maybe the keys should be just '4' and '6' instead of 'IPv4' and 'IPv6'? Harder to make capitalization mistakes that way.

#Comment by OverlordQ (talk | contribs)   00:21, 11 January 2010

The latter maybe, but according to the man page on MW, Introduced in version: 1.16.0 (r58377)

How much backwards compatibility do you need for an unreleased version (WMF-aside).

#Comment by Simetrical (talk | contribs)   01:01, 11 January 2010

Oh, it was introduced since the last release. A breaking format change is probably okay, then.

Status & tagging log