Index: trunk/phase3/includes/Block.php |
— | — | @@ -1057,6 +1057,19 @@ |
1058 | 1058 | return array( null, null ); |
1059 | 1059 | } |
1060 | 1060 | |
| 1061 | + if ( IP::isValid( $target ) ) { |
| 1062 | + # We can still create a User if it's an IP address, but we need to turn |
| 1063 | + # off validation checking (which would exclude IP addresses) |
| 1064 | + return array( |
| 1065 | + User::newFromName( IP::sanitizeIP( $target ), false ), |
| 1066 | + Block::TYPE_IP |
| 1067 | + ); |
| 1068 | + |
| 1069 | + } elseif ( IP::isValidBlock( $target ) ) { |
| 1070 | + # Can't create a User from an IP range |
| 1071 | + return array( IP::sanitizeRange( $target ), Block::TYPE_RANGE ); |
| 1072 | + } |
| 1073 | + |
1061 | 1074 | # Consider the possibility that this is not a username at all |
1062 | 1075 | # but actually an old subpage (bug #29797) |
1063 | 1076 | if( strpos( $target, '/' ) !== false ){ |
— | — | @@ -1072,18 +1085,6 @@ |
1073 | 1086 | # since hash characters are not valid in usernames or titles generally. |
1074 | 1087 | return array( $userObj, Block::TYPE_USER ); |
1075 | 1088 | |
1076 | | - } elseif ( IP::isValid( $target ) ) { |
1077 | | - # We can still create a User if it's an IP address, but we need to turn |
1078 | | - # off validation checking (which would exclude IP addresses) |
1079 | | - return array( |
1080 | | - User::newFromName( IP::sanitizeIP( $target ), false ), |
1081 | | - Block::TYPE_IP |
1082 | | - ); |
1083 | | - |
1084 | | - } elseif ( IP::isValidBlock( $target ) ) { |
1085 | | - # Can't create a User from an IP range |
1086 | | - return array( IP::sanitizeRange( $target ), Block::TYPE_RANGE ); |
1087 | | - |
1088 | 1089 | } elseif ( preg_match( '/^#\d+$/', $target ) ) { |
1089 | 1090 | # Autoblock reference in the form "#12345" |
1090 | 1091 | return array( substr( $target, 1 ), Block::TYPE_AUTO ); |