jenkins-bot has submitted this change and it was merged.
Change subject: Drop type prefixes because all values are strings in HTML (and
wikitext)
......................................................................
Drop type prefixes because all values are strings in HTML (and wikitext)
Change-Id: I8655393320064dd8d6f8f06abff6d5abc0baa795
---
M TemplateDataBlob.php
M spec.templatedata.json
M tests/TemplateDataBlobTest.php
3 files changed, 48 insertions(+), 8 deletions(-)
Approvals:
Bartosz Dziewoński: Looks good to me, approved
jenkins-bot: Verified
diff --git a/TemplateDataBlob.php b/TemplateDataBlob.php
index 19b9579..6611998 100644
--- a/TemplateDataBlob.php
+++ b/TemplateDataBlob.php
@@ -93,12 +93,18 @@
);
static $types = array(
- 'unknown',
- 'string',
+ 'line',
'number',
- 'string/wiki-page-name',
- 'string/wiki-user-name',
- 'string/line',
+ 'string',
+ 'unknown',
+ 'wiki-page-name',
+ 'wiki-user-name',
+ );
+
+ static $typeCompatMap = array(
+ 'string/line' => 'line',
+ 'string/wiki-page-name' => 'wiki-page-name',
+ 'string/wiki-user-name' => 'wiki-user-name',
);
if ( $data === null ) {
@@ -250,6 +256,12 @@
'string'
);
}
+
+ // Map deprecated types to newer versions
+ if ( isset( $typeCompatMap[ $paramObj->type ] )
) {
+ $paramObj->type = $typeCompatMap[
$paramObj->type ];
+ }
+
if ( !in_array( $paramObj->type, $types ) ) {
return Status::newFatal(
'templatedata-invalid-value',
diff --git a/spec.templatedata.json b/spec.templatedata.json
index 7183401..a232bc1 100644
--- a/spec.templatedata.json
+++ b/spec.templatedata.json
@@ -48,13 +48,13 @@
Any textual value.
- number
Any numerical value (without decimal points or thousand separators).
- - string/wiki-page-name
+ - wiki-page-name
A valid MediaWiki page name for the current wiki. Doesn't have to
exist,
but if not, should be a valid page name to create.
- - string/wiki-user-name
+ - wiki-user-name
A valid MediaWiki user name for the current wiki. Doesn't have to
exist,
but if not should be a valid user name to create.
- - string/line
+ - line
Short text field - use for names, labels, and other short-form fields.
@structure {string|Object} InterfaceText
diff --git a/tests/TemplateDataBlobTest.php b/tests/TemplateDataBlobTest.php
index 9ae6bdf..a8d8f2d 100644
--- a/tests/TemplateDataBlobTest.php
+++ b/tests/TemplateDataBlobTest.php
@@ -101,6 +101,34 @@
),
array(
'input' => '{
+ "params": {
+ "comment": {
+ "type": "string/line"
+ }
+ }
+ }
+ ',
+ 'output' => '{
+ "description": null,
+ "params": {
+ "comment": {
+ "label": null,
+ "description": null,
+ "default": "",
+ "required": false,
+ "deprecated": false,
+ "aliases": [],
+ "type": "line"
+ }
+ },
+ "paramOrder": ["comment"],
+ "sets": []
+ }
+ ',
+ 'msg' => 'Old string/* types are mapped to the
unprefixed versions'
+ ),
+ array(
+ 'input' => '{
"description": "User badge MediaWiki
developers.",
"params": {
"nickname": {
--
To view, visit https://gerrit.wikimedia.org/r/91623
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I8655393320064dd8d6f8f06abff6d5abc0baa795
Gerrit-PatchSet: 9
Gerrit-Project: mediawiki/extensions/TemplateData
Gerrit-Branch: master
Gerrit-Owner: Krinkle <[email protected]>
Gerrit-Reviewer: Bartosz Dziewoński <[email protected]>
Gerrit-Reviewer: Catrope <[email protected]>
Gerrit-Reviewer: Trevor Parscal <[email protected]>
Gerrit-Reviewer: jenkins-bot
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits