From dd9fa238cfab0f0715d4faefd03b720ae03a2b04 Mon Sep 17 00:00:00 2001 From: Dayllan Maza Date: Tue, 2 Apr 2019 12:33:11 -0400 Subject: [PATCH] Fix wpCreateAccount bug when set on Special:Block url params 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 | 20 ++++---------------- resources/src/mediawiki.special.block.js | 2 +- 2 files changed, 5 insertions(+), 17 deletions(-) diff --git a/includes/specials/SpecialBlock.php b/includes/specials/SpecialBlock.php index 0cf790bdda..b558d5ec4f 100644 --- a/includes/specials/SpecialBlock.php +++ b/includes/specials/SpecialBlock.php @@ -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 diff --git a/resources/src/mediawiki.special.block.js b/resources/src/mediawiki.special.block.js index 3e6f684515..b46df8575b 100644 --- a/resources/src/mediawiki.special.block.js +++ b/resources/src/mediawiki.special.block.js @@ -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() { -- 2.20.1