Code style cleanups, use strict comparison with $data['PreviousTarget'] per CR
[lhc/web/wiklou.git] / includes / specials / SpecialBlock.php
index bf06f62..299d758 100644 (file)
@@ -48,7 +48,7 @@ class SpecialBlock extends SpecialPage {
 
        /// @var Bool
        protected $alreadyBlocked;
-       
+
        /// @var Array
        protected $preErrors = array();
 
@@ -486,7 +486,8 @@ class SpecialBlock extends SpecialPage {
                if( $type == Block::TYPE_USER ){
                        # TODO: why do we not have a User->exists() method?
                        if( !$target->getId() ){
-                               return wfMessage( 'nosuchusershort', $target->getName() );
+                               return wfMessage( 'nosuchusershort',
+                                       wfEscapeWikiText( $target->getName() ) );
                        }
 
                        $status = self::checkUnblockSelf( $target );
@@ -553,7 +554,8 @@ class SpecialBlock extends SpecialPage {
                        # Give admins a heads-up before they go and block themselves.  Much messier
                        # to do this for IPs, but it's pretty unlikely they'd ever get the 'block'
                        # permission anyway, although the code does allow for it
-                       if( $target === $wgUser->getName() && ( $data['PreviousTarget'] != $data['Target'] || !$data['Confirm'] ) )
+                       if( $target === $wgUser->getName() &&
+                               ( $data['PreviousTarget'] != $data['Target'] || !$data['Confirm'] ) )
                        {
                                return array( 'ipb-blockingself' );
                        }
@@ -633,7 +635,9 @@ class SpecialBlock extends SpecialPage {
                $status = $block->insert();
                if( !$status ) {
                        # Show form unless the user is already aware of this...
-                       if( ( $data['PreviousTarget'] != htmlspecialchars( $block->getTarget() ) ) || !$data['Confirm'] ) {
+                       if( !$data['Confirm'] || ( array_key_exists( 'PreviousTarget', $data )
+                               && $data['PreviousTarget'] !== htmlspecialchars( $block->getTarget() ) ) )
+                       {
                                return array( array( 'ipb_already_blocked', $block->getTarget() ) );
                        # Otherwise, try to update the block...
                        } else {