[MediaWiki-commits] [Gerrit] mediawiki...OAuth[master]: Use HTMLRestrictionsField
jenkins-bot has submitted this change and it was merged. ( https://gerrit.wikimedia.org/r/311891 ) Change subject: Use HTMLRestrictionsField .. Use HTMLRestrictionsField Change-Id: I8c2a2713e94b0254d840bd71044a6cc1318a1b7c Depends-On: Ib50238e3be5eec63eb5df97154b60dc4ca33d581 --- M control/MWOAuthConsumerSubmitControl.php M frontend/specialpages/SpecialMWOAuthConsumerRegistration.php 2 files changed, 6 insertions(+), 26 deletions(-) Approvals: Bartosz Dziewoński: Looks good to me, approved jenkins-bot: Verified diff --git a/control/MWOAuthConsumerSubmitControl.php b/control/MWOAuthConsumerSubmitControl.php index 13d7e9a..604fcbe 100644 --- a/control/MWOAuthConsumerSubmitControl.php +++ b/control/MWOAuthConsumerSubmitControl.php @@ -90,14 +90,6 @@ $grants = \FormatJson::decode( $s, true ); return is_array( $grants ) && MWOAuthUtils::grantsAreValid( $grants ); }, - 'restrictions' => function( $s ) { - try { - \MWRestrictions::newFromJson( $s ); - return true; - } catch ( \InvalidArgumentException $ex ) { - return false; - } - }, 'rsaKey' => $validateRsaKey, 'agreement'=> function( $s ) { return ( $s == true ); @@ -105,14 +97,6 @@ ], 'update' => [ 'consumerKey' => '/^[0-9a-f]{32}$/', - 'restrictions' => function( $s ) { - try { - \MWRestrictions::newFromJson( $s ); - return true; - } catch ( \InvalidArgumentException $ex ) { - return false; - } - }, 'rsaKey' => $validateRsaKey, 'resetSecret' => function( $s ) { return is_bool( $s ); @@ -245,7 +229,7 @@ 'stage' => $stage, 'stageTimestamp' => $now, 'grants' => $grants, - 'restrictions' => \MWRestrictions::newFromJson( $this->vals['restrictions'] ), + 'restrictions' => $this->vals['restrictions'], 'deleted'=> 0 ] + $this->vals ); @@ -297,7 +281,7 @@ $cmr->setFields( [ 'rsaKey' => $this->vals['rsaKey'], - 'restrictions' => \MWRestrictions::newFromJson( $this->vals['restrictions'] ), + 'restrictions' => $this->vals['restrictions'], 'secretKey'=> $this->vals['resetSecret'] ? \MWCryptRand::generateHex( 32 ) : $cmr->get( 'secretKey' ) diff --git a/frontend/specialpages/SpecialMWOAuthConsumerRegistration.php b/frontend/specialpages/SpecialMWOAuthConsumerRegistration.php index 53d7494..982e1ce 100644 --- a/frontend/specialpages/SpecialMWOAuthConsumerRegistration.php +++ b/frontend/specialpages/SpecialMWOAuthConsumerRegistration.php @@ -180,11 +180,9 @@ 'validation-callback' => null // different format ], 'restrictions' => [ - 'type' => 'textarea', - 'label-message' => 'mwoauth-consumer-restrictions-json', + 'class' => 'HTMLRestrictionsField', 'required' => true, - 'default' => \MWRestrictions::newDefault()->toJson( true ), - 'rows' => 5 + 'default' => \MWRestrictions::newDefault(), ], 'rsaKey' => [
[MediaWiki-commits] [Gerrit] mediawiki...OAuth[master]: Use HTMLRestrictionsField
Gergő Tisza has uploaded a new change for review. https://gerrit.wikimedia.org/r/311891 Change subject: Use HTMLRestrictionsField .. Use HTMLRestrictionsField Change-Id: I8c2a2713e94b0254d840bd71044a6cc1318a1b7c Depends-On: Ib50238e3be5eec63eb5df97154b60dc4ca33d581 --- M control/MWOAuthConsumerSubmitControl.php M frontend/specialpages/SpecialMWOAuthConsumerRegistration.php 2 files changed, 6 insertions(+), 26 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/OAuth refs/changes/91/311891/1 diff --git a/control/MWOAuthConsumerSubmitControl.php b/control/MWOAuthConsumerSubmitControl.php index a987621..32c4f8c 100644 --- a/control/MWOAuthConsumerSubmitControl.php +++ b/control/MWOAuthConsumerSubmitControl.php @@ -88,14 +88,6 @@ $grants = \FormatJson::decode( $s, true ); return is_array( $grants ) && MWOAuthUtils::grantsAreValid( $grants ); }, - 'restrictions' => function( $s ) { - try { - \MWRestrictions::newFromJson( $s ); - return true; - } catch ( \InvalidArgumentException $ex ) { - return false; - } - }, 'rsaKey' => $validateRsaKey, 'agreement'=> function( $s ) { return ( $s == true ); @@ -103,14 +95,6 @@ ), 'update' => array( 'consumerKey' => '/^[0-9a-f]{32}$/', - 'restrictions' => function( $s ) { - try { - \MWRestrictions::newFromJson( $s ); - return true; - } catch ( \InvalidArgumentException $ex ) { - return false; - } - }, 'rsaKey' => $validateRsaKey, 'resetSecret' => function( $s ) { return is_bool( $s ); }, 'reason' => '/^.{0,255}$/', @@ -242,7 +226,7 @@ 'stage' => $stage, 'stageTimestamp' => $now, 'grants' => $grants, - 'restrictions' => \MWRestrictions::newFromJson( $this->vals['restrictions'] ), + 'restrictions' => $this->vals['restrictions'], 'deleted'=> 0 ) + $this->vals ); @@ -295,7 +279,7 @@ $cmr->setFields( array( 'rsaKey' => $this->vals['rsaKey'], - 'restrictions' => \MWRestrictions::newFromJson( $this->vals['restrictions'] ), + 'restrictions' => $this->vals['restrictions'], 'secretKey'=> $this->vals['resetSecret'] ? \MWCryptRand::generateHex( 32 ) : $cmr->get( 'secretKey' ) diff --git a/frontend/specialpages/SpecialMWOAuthConsumerRegistration.php b/frontend/specialpages/SpecialMWOAuthConsumerRegistration.php index 3d4ad9f..13d93bb 100644 --- a/frontend/specialpages/SpecialMWOAuthConsumerRegistration.php +++ b/frontend/specialpages/SpecialMWOAuthConsumerRegistration.php @@ -177,11 +177,9 @@ 'validation-callback' => null // different format ), 'restrictions' => array( - 'type' => 'textarea', - 'label-message' => 'mwoauth-consumer-restrictions-json', + 'class' => 'HTMLRestrictionsField', 'required' => true, - 'default' => \MWRestrictions::newDefault()->toJson( true ), - 'rows' => 5 + 'default' => \MWRestrictions::newDefault(), ), 'rsaKey' => array(