Merge "(bug 34211) Initial focus on Special:Block is nowhere"
authorjenkins-bot <jenkins-bot@gerrit.wikimedia.org>
Tue, 5 Feb 2013 18:15:25 +0000 (18:15 +0000)
committerGerrit Code Review <gerrit@wikimedia.org>
Tue, 5 Feb 2013 18:15:25 +0000 (18:15 +0000)
1  2 
includes/specials/SpecialBlock.php

@@@ -62,7 -62,7 +62,7 @@@ class SpecialBlock extends FormSpecialP
         * @throws ErrorPageError
         */
        protected function checkExecutePermissions( User $user ) {
 -               parent::checkExecutePermissions( $user );
 +              parent::checkExecutePermissions( $user );
  
                # bug 15810: blocked admins should have limited access here
                $status = self::checkUnblockSelf( $this->target, $user );
                                'tabindex' => '1',
                                'id' => 'mw-bi-target',
                                'size' => '45',
+                               'autofocus' => true,
                                'required' => true,
                                'validation-callback' => array( __CLASS__, 'validateTargetField' ),
                        ),
  
                if ( $block instanceof Block && !$block->mAuto # The block exists and isn't an autoblock
                        && ( $this->type != Block::TYPE_RANGE # The block isn't a rangeblock
 -                        || $block->getTarget() == $this->target ) # or if it is, the range is what we're about to block
 +                              || $block->getTarget() == $this->target ) # or if it is, the range is what we're about to block
                        )
                {
                        $fields['HardBlock']['default'] = $block->isHardblock();
                        );
                }
  
 -              $text =  Html::rawElement(
 +              $text = Html::rawElement(
                        'p',
                        array( 'class' => 'mw-ipb-conveniencelinks' ),
                        $this->getLanguage()->pipeList( $links )
                }
  
                if ( $data['HideUser'] ) {
 -                      if ( !$performer->isAllowed('hideuser') ) {
 +                      if ( !$performer->isAllowed( 'hideuser' ) ) {
                                # this codepath is unreachable except by a malicious user spoofing forms,
                                # or by race conditions (user has oversight and sysop, loads block form,
                                # and is de-oversighted before submission); so need to fail completely
                # Try to insert block. Is there a conflicting block?
                $status = $block->insert();
                if ( !$status ) {
 +                      # Indicates whether the user is confirming the block and is aware of
 +                      # the conflict (did not change the block target in the meantime)
 +                      $blockNotConfirmed = !$data['Confirm'] || ( array_key_exists( 'PreviousTarget', $data )
 +                              && $data['PreviousTarget'] !== $target );
 +
 +                      # Special case for API - bug 32434
 +                      $reblockNotAllowed = ( array_key_exists( 'Reblock', $data ) && !$data['Reblock'] );
 +
                        # Show form unless the user is already aware of this...
 -                      if ( !$data['Confirm'] || ( array_key_exists( 'PreviousTarget', $data )
 -                              && $data['PreviousTarget'] !== $target ) )
 -                      {
 +                      if( $blockNotConfirmed || $reblockNotAllowed ) {
                                return array( array( 'ipb_already_blocked', $block->getTarget() ) );
                        # Otherwise, try to update the block...
                        } else {
                        $logParams
                );
                # Relate log ID to block IDs (bug 25763)
 -              $blockIds = array_merge( array( $status['id'] ), $status['autoIds']  );
 +              $blockIds = array_merge( array( $status['id'] ), $status['autoIds'] );
                $log->addRelations( 'ipb_id', $blockIds, $log_id );
  
                # Report to the user