CSteipp has submitted this change and it was merged. Change subject: Made use of field-specific HTMLForm errors more ......................................................................
Made use of field-specific HTMLForm errors more * This follows up 300b9546e18675ea76bfb1e5a7ef9a56671c53d5. Change-Id: I32bf8767ccd5dfe49a0836b54156438c9c511934 --- M frontend/specialpages/SpecialMWOAuthConsumerRegistration.php M frontend/specialpages/SpecialMWOAuthManageConsumers.php 2 files changed, 26 insertions(+), 19 deletions(-) Approvals: CSteipp: Verified; Looks good to me, approved jenkins-bot: Verified diff --git a/frontend/specialpages/SpecialMWOAuthConsumerRegistration.php b/frontend/specialpages/SpecialMWOAuthConsumerRegistration.php index ce30d3c..f782695 100644 --- a/frontend/specialpages/SpecialMWOAuthConsumerRegistration.php +++ b/frontend/specialpages/SpecialMWOAuthConsumerRegistration.php @@ -197,8 +197,10 @@ } $oldSecretKey = $cmr->getDAO()->get( 'secretKey' ); + $dbw = MWOAuthUtils::getCentralDB( DB_MASTER ); // @TODO: lazy handle + $control = new MWOAuthConsumerSubmitControl( $this->getContext(), array(), $dbw ); $form = new HTMLForm( - array( + $control->registerValidators( array( 'nameShown' => array( 'type' => 'info', 'label-message' => 'mwoauth-consumer-name', @@ -252,14 +254,15 @@ 'type' => 'hidden', 'default' => 'update' ) - ), + ) ), $this->getContext() ); - $form->setSubmitCallback( function( array $data, IContextSource $context ) { - $dbw = MWOAuthUtils::getCentralDB( DB_MASTER ); - $controller = new MWOAuthConsumerSubmitControl( $context, $data, $dbw ); - return $controller->submit(); - } ); + $form->setSubmitCallback( + function( array $data, IContextSource $context ) use ( $control ) { + $control->setInputParameters( $data ); + return $control->submit(); + } + ); $form->setWrapperLegendMsg( 'mwoauthconsumerregistration-update-legend' ); $form->setSubmitTextMsg( 'mwoauthconsumerregistration-update-submit' ); $form->addPreText( diff --git a/frontend/specialpages/SpecialMWOAuthManageConsumers.php b/frontend/specialpages/SpecialMWOAuthManageConsumers.php index 450fa35..9230494 100644 --- a/frontend/specialpages/SpecialMWOAuthManageConsumers.php +++ b/frontend/specialpages/SpecialMWOAuthManageConsumers.php @@ -236,8 +236,11 @@ $opts["<strong>$msg</strong>"] = 'dsuppress'; } } + + $dbw = MWOAuthUtils::getCentralDB( DB_MASTER ); // @TODO: lazy handle + $control = new MWOAuthConsumerSubmitControl( $this->getContext(), array(), $dbw ); $form = new HTMLForm( - array( + $control->registerValidators( array( 'consumerKeyShown' => array( 'type' => 'info', 'label-message' => 'mwoauth-consumer-key', @@ -330,20 +333,21 @@ 'type' => 'hidden', 'default' => $cmr->getDAO()->getChangeToken( $this->getContext() ) ), - ), + ) ), $this->getContext() ); - $form->setSubmitCallback( function( array $data, IContextSource $context ) { - $data['suppress'] = 0; - if ( $data['action'] === 'dsuppress' ) { - $data = array( 'action' => 'disable', 'suppress' => 1 ) + $data; - } elseif ( $data['action'] === 'rsuppress' ) { - $data = array( 'action' => 'reject', 'suppress' => 1 ) + $data; + $form->setSubmitCallback( + function( array $data, IContextSource $context ) use ( $control ) { + $data['suppress'] = 0; + if ( $data['action'] === 'dsuppress' ) { + $data = array( 'action' => 'disable', 'suppress' => 1 ) + $data; + } elseif ( $data['action'] === 'rsuppress' ) { + $data = array( 'action' => 'reject', 'suppress' => 1 ) + $data; + } + $control->setInputParameters( $data ); + return $control->submit(); } - $dbw = MWOAuthUtils::getCentralDB( DB_MASTER ); - $controller = new MWOAuthConsumerSubmitControl( $context, $data, $dbw ); - return $controller->submit(); - } ); + ); $form->setWrapperLegendMsg( 'mwoauthmanageconsumers-confirm-legend' ); $form->setSubmitTextMsg( 'mwoauthmanageconsumers-confirm-submit' ); -- To view, visit https://gerrit.wikimedia.org/r/82060 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: merged Gerrit-Change-Id: I32bf8767ccd5dfe49a0836b54156438c9c511934 Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/OAuth Gerrit-Branch: master Gerrit-Owner: Aaron Schulz <asch...@wikimedia.org> Gerrit-Reviewer: CSteipp <cste...@wikimedia.org> Gerrit-Reviewer: jenkins-bot _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits