diff --git a/includes/TemplateDataBlob.php b/includes/TemplateDataBlob.php index 108b6a9f..8546b613 100644 --- a/includes/TemplateDataBlob.php +++ b/includes/TemplateDataBlob.php @@ -312,10 +312,12 @@ class TemplateDataBlob { return Status::newFatal( 'templatedata-invalid-type', "params.{$paramName}.aliases", 'array' ); } - foreach ( $paramObj->aliases as $i => $alias ) { - if ( !is_string( $alias ) ) { + foreach ( $paramObj->aliases as $i => &$alias ) { + if ( is_int( $alias ) ) { + $alias = (string)$alias; + } elseif ( !is_string( $alias ) ) { return Status::newFatal( 'templatedata-invalid-type', - "params.{$paramName}.aliases[$i]", 'string' ); + "params.{$paramName}.aliases[$i]", 'int|string' ); } } } else { diff --git a/modules/ext.templateDataGenerator.editTemplatePage/Dialog.js b/modules/ext.templateDataGenerator.editTemplatePage/Dialog.js index 7fb59a6b..5cd00298 100644 --- a/modules/ext.templateDataGenerator.editTemplatePage/Dialog.js +++ b/modules/ext.templateDataGenerator.editTemplatePage/Dialog.js @@ -1103,6 +1103,11 @@ Dialog.prototype.changeParamPropertyInput = function ( paramKey, propName, value propInput.selectItem( propInput.findItemFromData( value ) ); } else if ( prop.type === 'boolean' ) { propInput.setSelected( !!value ); + } else if ( prop.type === 'array' ) { + propInput.setValue( value.map( function ( v ) { + // TagMultiselectWidget accepts nothing but strings or objects with a .data property + return v && v.data ? v : String( v ); + } ) ); } else { if ( languageProps.indexOf( propName ) !== -1 ) { propInput.setValue( value[ lang ] ); diff --git a/tests/phpunit/TemplateDataBlobTest.php b/tests/phpunit/TemplateDataBlobTest.php index a2678d6d..98ee5b68 100644 --- a/tests/phpunit/TemplateDataBlobTest.php +++ b/tests/phpunit/TemplateDataBlobTest.php @@ -114,6 +114,10 @@ class TemplateDataBlobTest extends MediaWikiIntegrationTestCase { 'input' => '{ "params": { "a": { "aliases": "" } } }', 'status' => '(templatedata-invalid-type: params.a.aliases, array)', ], + [ + 'input' => '{ "params": { "a": { "aliases": [ "1", 2, {} ] } } }', + 'status' => '(templatedata-invalid-type: params.a.aliases[2], int|string)', + ], [ 'input' => '{ "params": { "a": { "autovalue": [] } } }', 'status' => '(templatedata-invalid-type: params.a.autovalue, string)', @@ -134,6 +138,10 @@ class TemplateDataBlobTest extends MediaWikiIntegrationTestCase { 'input' => '{ "params": { "a": { "suggestedvalues": "" } } }', 'status' => '(templatedata-invalid-type: params.a.suggestedvalues, array)', ], + [ + 'input' => '{ "params": { "a": { "suggestedvalues": [ {} ] } } }', + 'status' => '(templatedata-invalid-type: params.a.suggestedvalues[0], string)', + ], [ 'input' => '{ "params": { @@ -209,9 +217,7 @@ class TemplateDataBlobTest extends MediaWikiIntegrationTestCase { "example": null, "required": false, "suggested": true, - "aliases": [ - "1" - ] + "aliases": [ 1 ] } } }