Index: trunk/phase3/includes/specials/SpecialBlock.php |
— | — | @@ -203,7 +203,7 @@ |
204 | 204 | * already blocked) |
205 | 205 | */ |
206 | 206 | protected function maybeAlterFormDefaults( &$fields ){ |
207 | | - $fields['Target']['default'] = $this->target; |
| 207 | + $fields['Target']['default'] = (string)$this->target; |
208 | 208 | |
209 | 209 | $block = self::getBlockFromTargetAndType( $this->target, $this->type ); |
210 | 210 | |
— | — | @@ -454,10 +454,10 @@ |
455 | 455 | * @since 1.18 |
456 | 456 | * @return Message |
457 | 457 | */ |
458 | | - public static function validateTargetField( $data, $alldata = null ) { |
| 458 | + public static function validateTargetField( $value, $alldata = null ) { |
459 | 459 | global $wgBlockCIDRLimit; |
460 | 460 | |
461 | | - list( $target, $type ) = self::getTargetAndType( $data ); |
| 461 | + list( $target, $type ) = self::getTargetAndType( $value ); |
462 | 462 | |
463 | 463 | if( $type == Block::TYPE_USER ){ |
464 | 464 | # TODO: why do we not have a User->exists() method? |
— | — | @@ -470,10 +470,6 @@ |
471 | 471 | return wfMessage( 'badaccess', $status ); |
472 | 472 | } |
473 | 473 | |
474 | | - $user = $target; |
475 | | - $target = $user->getName(); |
476 | | - $userId = $user->getId(); |
477 | | - |
478 | 474 | } elseif( $type == Block::TYPE_RANGE ){ |
479 | 475 | list( $ip, $range ) = explode( '/', $target, 2 ); |
480 | 476 | |
— | — | @@ -499,16 +495,14 @@ |
500 | 496 | return wfMessage( 'ip_range_toolarge', $wgBlockCIDRLimit['IPv6'] ); |
501 | 497 | } |
502 | 498 | |
503 | | - $userId = 0; |
504 | | - |
505 | 499 | } elseif( $type == Block::TYPE_IP ){ |
506 | 500 | # All is well |
507 | | - $target = $target->getName(); |
508 | | - $userId = 0; |
509 | 501 | |
510 | 502 | } else { |
511 | 503 | return wfMessage( 'badipaddress' ); |
512 | 504 | } |
| 505 | + |
| 506 | + return true; |
513 | 507 | } |
514 | 508 | |
515 | 509 | /** |
— | — | @@ -522,6 +516,21 @@ |
523 | 517 | // Handled by field validator callback |
524 | 518 | // self::validateTargetField( $data['Target'] ); |
525 | 519 | |
| 520 | + list( $target, $type ) = self::getTargetAndType( $data['Target'] ); |
| 521 | + if( $type == Block::TYPE_USER ){ |
| 522 | + $user = $target; |
| 523 | + $target = $user->getName(); |
| 524 | + $userId = $user->getId(); |
| 525 | + } elseif( $type == Block::TYPE_RANGE ){ |
| 526 | + $userId = 0; |
| 527 | + } elseif( $type == Block::TYPE_IP ){ |
| 528 | + $target = $target->getName(); |
| 529 | + $userId = 0; |
| 530 | + } else { |
| 531 | + # This should have been caught in the form field validation |
| 532 | + return wfMessage( 'badipaddress' ); |
| 533 | + } |
| 534 | + |
526 | 535 | if( ( strlen( $data['Expiry'] ) == 0) || ( strlen( $data['Expiry'] ) > 50 ) |
527 | 536 | || !Block::parseExpiryInput( $data['Expiry'] ) ) |
528 | 537 | { |