Merge "Use the same object when checking if the user is blocked instead of creating...
authorDemon <chadh@wikimedia.org>
Fri, 4 May 2012 14:09:05 +0000 (14:09 +0000)
committerGerrit Code Review <gerrit@wikimedia.org>
Fri, 4 May 2012 14:09:05 +0000 (14:09 +0000)
includes/Block.php
includes/User.php

index 42504be..7cdc756 100644 (file)
@@ -1080,8 +1080,6 @@ class Block {
         * @return array( User|String, Block::TYPE_ constant )
         */
        public static function parseTarget( $target ) {
-               $target = trim( $target );
-
                # We may have been through this before
                if( $target instanceof User ){
                        if( IP::isValid( $target->getName() ) ){
@@ -1093,6 +1091,8 @@ class Block {
                        return array( null, null );
                }
 
+               $target = trim( $target );
+
                if ( IP::isValid( $target ) ) {
                        # We can still create a User if it's an IP address, but we need to turn
                        # off validation checking (which would exclude IP addresses)
index 793714d..2f3bcdc 100644 (file)
@@ -1283,7 +1283,7 @@ class User {
                }
 
                # User/IP blocking
-               $block = Block::newFromTarget( $this->getName(), $ip, !$bFromSlave );
+               $block = Block::newFromTarget( $this, $ip, !$bFromSlave );
 
                # Proxy blocking
                if ( !$block instanceof Block && $ip !== null && !$this->isAllowed( 'proxyunbannable' )