aboutsummaryrefslogtreecommitdiffstats
path: root/includes/api/Validator
diff options
context:
space:
mode:
authorMichael Große <mgrosse@wikimedia.org>2025-03-06 14:04:40 +0100
committerMichael Große <mgrosse@wikimedia.org>2025-03-07 09:20:41 +0100
commit6681302aab823778614d74edf4c0f1a38161590b (patch)
tree61634ed452fb8bc9de6aea8996889aac2a0c386a /includes/api/Validator
parent8374e629634edc54ada5748fdbdcf839aa522ccb (diff)
downloadmediawikicore-6681302aab823778614d74edf4c0f1a38161590b.tar.gz
mediawikicore-6681302aab823778614d74edf4c0f1a38161590b.zip
fix(ApiParamValidator): PARAM_HELP_MSG_PER_VALUE for multi-string types
In I53f9ae840c (commit 7c03a6f), the option was added to use PARAM_HELP_MSG_PER_VALUE to also document parameters for multi-string types, like templated parameters. See there for the reasoning. This change adds the support in ApiParamValidator for that. Follow-Up-To: I53f9ae840c0a7eee76c4b57f95390b5045707efd Change-Id: Ia8c1abdcb68823650582208caa9be3fa2c47daa8
Diffstat (limited to 'includes/api/Validator')
-rw-r--r--includes/api/Validator/ApiParamValidator.php13
1 files changed, 11 insertions, 2 deletions
diff --git a/includes/api/Validator/ApiParamValidator.php b/includes/api/Validator/ApiParamValidator.php
index 8072d2d668ff..e451400aa000 100644
--- a/includes/api/Validator/ApiParamValidator.php
+++ b/includes/api/Validator/ApiParamValidator.php
@@ -247,12 +247,21 @@ class ApiParamValidator {
}
if ( isset( $settings[ApiBase::PARAM_HELP_MSG_PER_VALUE] ) ) {
+ // ! keep these checks in sync with \MediaWiki\Api\ApiBase::getFinalParamDescription
if ( !is_array( $settings[ApiBase::PARAM_HELP_MSG_PER_VALUE] ) ) {
$ret['issues'][ApiBase::PARAM_HELP_MSG_PER_VALUE] = 'PARAM_HELP_MSG_PER_VALUE must be an array,'
. ' got ' . gettype( $settings[ApiBase::PARAM_HELP_MSG_PER_VALUE] );
- } elseif ( !is_array( $settings[ParamValidator::PARAM_TYPE] ?? '' ) ) {
+ } elseif ( !( is_array( $settings[ParamValidator::PARAM_TYPE] ?? '' ) || (
+ $settings[ParamValidator::PARAM_TYPE] === 'string'
+ && ( $settings[ParamValidator::PARAM_ISMULTI] ?? false )
+ ) ) ) {
$ret['issues'][ApiBase::PARAM_HELP_MSG_PER_VALUE] = 'PARAM_HELP_MSG_PER_VALUE can only be used '
- . 'with PARAM_TYPE as an array';
+ . 'with PARAM_TYPE as an array, or PARAM_TYPE = string and PARAM_ISMULTI = true';
+ } elseif ( $settings[ParamValidator::PARAM_TYPE] === 'string'
+ && ( $settings[ParamValidator::PARAM_ISMULTI] ?? false ) ) {
+ foreach ( $settings[ApiBase::PARAM_HELP_MSG_PER_VALUE] as $k => $v ) {
+ $this->checkSettingsMessage( $module, "PARAM_HELP_MSG_PER_VALUE[$k]", $v, $ret );
+ }
} else {
$values = array_map( 'strval', $settings[ParamValidator::PARAM_TYPE] );
foreach ( $settings[ApiBase::PARAM_HELP_MSG_PER_VALUE] as $k => $v ) {