Fix wpCreateAccount bug when set on Special:Block url params
authorDayllan Maza <dmaza@wikimedia.org>
Tue, 2 Apr 2019 16:33:11 +0000 (12:33 -0400)
committerDayllan Maza <dmaza@wikimedia.org>
Wed, 3 Apr 2019 18:40:01 +0000 (14:40 -0400)
wpCreateAccount default is dynamically changed if the user
has not posted the form or interacted with the field in any way

Bug: T218554
Change-Id: Ied68dc60d57ed35ed3285c5cf89b772c8c4e41d1

includes/specials/SpecialBlock.php
resources/src/mediawiki.special.block.js

index 0cf790b..b558d5e 100644 (file)
@@ -308,18 +308,6 @@ 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
@@ -397,14 +385,14 @@ class SpecialBlock extends FormSpecialPage {
                                $fields['Expiry']['default'] = wfTimestamp( TS_RFC2822, $block->getExpiry() );
                        }
 
-                       $fields['BlockId']['default'] = $block->getId();
-
                        $this->alreadyBlocked = true;
                        $this->preErrors[] = [ 'ipb-needreblock', wfEscapeWikiText( (string)$block->getTarget() ) ];
                }
 
-               if ( $this->getRequest()->wasPosted() ) {
-                       $fields['WasPosted']['default'] = true;
+               if ( $this->alreadyBlocked || $this->getRequest()->wasPosted()
+                       || $this->getRequest()->getCheck( 'wpCreateAccount' )
+               ) {
+                       $this->getOutput()->addJsConfigVars( 'wgCreateAccountDirty', true );
                }
 
                # We always need confirmation to do HideUser
index 3e6f684..b46df85 100644 (file)
@@ -26,7 +26,7 @@
                        pageRestrictionsWidget = infuseIfExists( $( '#mw-input-wpPageRestrictions' ) ),
                        namespaceRestrictionsWidget = infuseIfExists( $( '#mw-input-wpNamespaceRestrictions' ) ),
                        createAccountWidget = infuseIfExists( $( '#mw-input-wpCreateAccount' ) ),
-                       userChangedCreateAccount = $( '#mw-input-wpBlockId' ).val() || $( '#mw-input-wpWasPosted' ).val() || false,
+                       userChangedCreateAccount = mw.config.get( 'wgCreateAccountDirty' ),
                        updatingBlockOptions = false;
 
                function updateBlockOptions() {