Aaron Schulz has uploaded a new change for review.
https://gerrit.wikimedia.org/r/77972
Change subject: Enforce version format and chronology
......................................................................
Enforce version format and chronology
Change-Id: I15ac28150d0368e60306f22ab9bc729506a9ed35
---
M control/MWOAuthConsumerSubmitControl.php
M frontend/language/MWOAuth.i18n.php
2 files changed, 18 insertions(+), 3 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/OAuth
refs/changes/72/77972/1
diff --git a/control/MWOAuthConsumerSubmitControl.php
b/control/MWOAuthConsumerSubmitControl.php
index b7dbe9d..30d7e61 100644
--- a/control/MWOAuthConsumerSubmitControl.php
+++ b/control/MWOAuthConsumerSubmitControl.php
@@ -43,7 +43,7 @@
// Proposer (application administrator) actions:
'propose' => array(
'name' => '/^.{1,128}$/',
- 'version' => '/^.{1,32}$/',
+ 'version' =>
'/^\d{1,3}\.\d{1,2}.\d{1,2}(-(dev|alpha|beta))?$/',
'callbackUrl' => function( $s ) {
return wfParseUrl( $s ) !== null; },
'description' => '/^.*$/',
@@ -140,6 +140,17 @@
return $this->failure( 'consumer_exists',
'mwoauth-consumer-alreadyexists' );
}
+ $curVer = $dbw->selectField(
'oauth_registered_consumer',
+ 'oarc_version',
+ array( 'oarc_name' => $this->vals['name'],
'oarc_user_id' => $centralUserId ),
+ __METHOD__,
+ array( 'ORDER BY' => 'oarc_registration DESC',
'FOR UPDATE' )
+ );
+ if ( $curVer !== false && version_compare( $curVer,
$this->vals['version'], '>=' ) ) {
+ return $this->failure( 'consumer_exists',
+
'mwoauth-consumer-alreadyexistsversion', $curVer );
+ }
+
$now = wfTimestampNow();
$cmr = MWOAuthConsumer::newFromArray(
array(
diff --git a/frontend/language/MWOAuth.i18n.php
b/frontend/language/MWOAuth.i18n.php
index 9be2340..197a3f1 100644
--- a/frontend/language/MWOAuth.i18n.php
+++ b/frontend/language/MWOAuth.i18n.php
@@ -23,7 +23,7 @@
'mwoauth-consumer-key' => 'Consumer key:',
'mwoauth-consumer-name' => 'Application name:',
- 'mwoauth-consumer-version' => 'Major version:',
+ 'mwoauth-consumer-version' => 'Consumer version:',
'mwoauth-consumer-user' => 'Publisher:',
'mwoauth-consumer-stage' => 'Current status:',
'mwoauth-consumer-email' => 'Contact email address:',
@@ -39,6 +39,7 @@
'mwoauth-consumer-accesstoken' => 'Access token:',
'mwoauth-consumer-reason' => 'Reason:',
'mwoauth-consumer-alreadyexists' => 'A consumer with this
name/version/publisher combination already exists',
+ 'mwoauth-consumer-alreadyexistsversion' => 'A consumer with this
name/publisher combination already exists with an equal or higher version
("$1")',
'mwoauth-consumer-not-accepted' => 'Cannot update information for a
pending consumer request',
'mwoauth-consumer-not-proposed' => 'The consumer is not currently
proposed',
'mwoauth-consumer-not-disabled' => 'The consumer is not currently
disabled',
@@ -63,7 +64,8 @@
A few recommendations and remarks:
* Try to use as few grants as possible. Avoid grants that are not actually
needed now.
-* Please provide an RSA key if possible; otherwise a (less secure) secret
token will be assigned to you.
+* Versions are of the form "major.minor.release" and increase as grant changes
are needed.
+* Please provide an RSA key if possible; otherwise a (less secure) secret
token will have to be used.
* Use the JSON restrictions field to limit access of this consumer to IP
addresses in those CIDR ranges.
* You can use a wiki ID to restrict the consumer to a single wiki on this site
(use "*" for all wikis).
* The email address provided must match that of your account (which must have
been confirmed).',
@@ -540,6 +542,8 @@
'action-mwoauthproposeconsumer' =>
'{{Doc-action|mwoauthproposeconsumer}}',
'action-mwoauthupdateconsumer' =>
'{{Doc-action|mwoauthupdateconsumer}}',
'action-mwoauthviewsuppressed' =>
'{{Doc-action|mwoauthviewsuppressed}}',
+ 'alreadyexistsversion' => 'Used as error message. Parameters:
+* $1 - the current consumer application version'
);
/** Asturian (asturianu)
--
To view, visit https://gerrit.wikimedia.org/r/77972
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I15ac28150d0368e60306f22ab9bc729506a9ed35
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/OAuth
Gerrit-Branch: master
Gerrit-Owner: Aaron Schulz <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits