r83824 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r83823‎ | r83824 | r83825 >
Date:14:41, 13 March 2011
Author:happy-melon
Status:ok
Tags:
Comment:
Fix totally-broken r83810.
Modified paths:
  • /trunk/phase3/includes/specials/SpecialBlock.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/specials/SpecialBlock.php
@@ -203,7 +203,7 @@
204204 * already blocked)
205205 */
206206 protected function maybeAlterFormDefaults( &$fields ){
207 - $fields['Target']['default'] = $this->target;
 207+ $fields['Target']['default'] = (string)$this->target;
208208
209209 $block = self::getBlockFromTargetAndType( $this->target, $this->type );
210210
@@ -454,10 +454,10 @@
455455 * @since 1.18
456456 * @return Message
457457 */
458 - public static function validateTargetField( $data, $alldata = null ) {
 458+ public static function validateTargetField( $value, $alldata = null ) {
459459 global $wgBlockCIDRLimit;
460460
461 - list( $target, $type ) = self::getTargetAndType( $data );
 461+ list( $target, $type ) = self::getTargetAndType( $value );
462462
463463 if( $type == Block::TYPE_USER ){
464464 # TODO: why do we not have a User->exists() method?
@@ -470,10 +470,6 @@
471471 return wfMessage( 'badaccess', $status );
472472 }
473473
474 - $user = $target;
475 - $target = $user->getName();
476 - $userId = $user->getId();
477 -
478474 } elseif( $type == Block::TYPE_RANGE ){
479475 list( $ip, $range ) = explode( '/', $target, 2 );
480476
@@ -499,16 +495,14 @@
500496 return wfMessage( 'ip_range_toolarge', $wgBlockCIDRLimit['IPv6'] );
501497 }
502498
503 - $userId = 0;
504 -
505499 } elseif( $type == Block::TYPE_IP ){
506500 # All is well
507 - $target = $target->getName();
508 - $userId = 0;
509501
510502 } else {
511503 return wfMessage( 'badipaddress' );
512504 }
 505+
 506+ return true;
513507 }
514508
515509 /**
@@ -522,6 +516,21 @@
523517 // Handled by field validator callback
524518 // self::validateTargetField( $data['Target'] );
525519
 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+
526535 if( ( strlen( $data['Expiry'] ) == 0) || ( strlen( $data['Expiry'] ) > 50 )
527536 || !Block::parseExpiryInput( $data['Expiry'] ) )
528537 {

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r83786Divert a river through the Augean Stables that is SpecialBlockip.php....happy-melon21:54, 12 March 2011
r83810* Moved Target field validation into a field validation callback to show erro...nikerabbit09:57, 13 March 2011

Status & tagging log