Merge "Fix account create checkbox bug"
authorjenkins-bot <jenkins-bot@gerrit.wikimedia.org>
Thu, 21 Mar 2019 14:03:21 +0000 (14:03 +0000)
committerGerrit Code Review <gerrit@wikimedia.org>
Thu, 21 Mar 2019 14:03:21 +0000 (14:03 +0000)
includes/specials/SpecialBlock.php
resources/src/mediawiki.special.block.js

index 7330e77..02a8d00 100644 (file)
@@ -308,6 +308,18 @@ class SpecialBlock extends FormSpecialPage {
                        'cssclass' => 'mw-block-confirm',
                ];
 
+               // Block Id if a block already exists matching the target
+               $a['BlockId'] = [
+                       'type' => 'hidden',
+                       'default' => '',
+               ];
+
+               // Has the form been submitted
+               $a['WasPosted'] = [
+                       'type' => 'hidden',
+                       'default' => '',
+               ];
+
                $this->maybeAlterFormDefaults( $a );
 
                // Allow extensions to add more fields
@@ -383,10 +395,16 @@ class SpecialBlock extends FormSpecialPage {
                                $fields['Expiry']['default'] = wfTimestamp( TS_RFC2822, $block->mExpiry );
                        }
 
+                       $fields['BlockId']['default'] = $block->getId();
+
                        $this->alreadyBlocked = true;
                        $this->preErrors[] = [ 'ipb-needreblock', wfEscapeWikiText( (string)$block->getTarget() ) ];
                }
 
+               if ( $this->getRequest()->wasPosted() ) {
+                       $fields['WasPosted']['default'] = true;
+               }
+
                # We always need confirmation to do HideUser
                if ( $this->requestedHideUser ) {
                        $fields['Confirm']['type'] = 'check';
index 02e380a..3e6f684 100644 (file)
@@ -26,7 +26,7 @@
                        pageRestrictionsWidget = infuseIfExists( $( '#mw-input-wpPageRestrictions' ) ),
                        namespaceRestrictionsWidget = infuseIfExists( $( '#mw-input-wpNamespaceRestrictions' ) ),
                        createAccountWidget = infuseIfExists( $( '#mw-input-wpCreateAccount' ) ),
-                       userChangedCreateAccount = false,
+                       userChangedCreateAccount = $( '#mw-input-wpBlockId' ).val() || $( '#mw-input-wpWasPosted' ).val() || false,
                        updatingBlockOptions = false;
 
                function updateBlockOptions() {