// $msg for ApiBase::makeMessage(). Any value not having a mapping will use
// apihelp-{$path}-paramvalue-{$param}-{$value} is used.
const PARAM_HELP_MSG_PER_VALUE = 14;
+ /// @since 1.26
+ // When PARAM_TYPE is 'submodule', map parameter values to submodule paths.
+ // Default is to use all modules in $this->getModuleManager() in the group
+ // matching the parameter name.
+ const PARAM_SUBMODULE_MAP = 15;
+ /// @since 1.26
+ // When PARAM_TYPE is 'submodule', used to indicate the 'g' prefix added by
+ // ApiQueryGeneratorBase (and similar if anything else ever does that).
+ const PARAM_SUBMODULE_PARAM_PREFIX = 16;
const LIMIT_BIG1 = 500; // Fast query, std user limit
const LIMIT_BIG2 = 5000; // Fast query, bot/sysop limit
$type = MWNamespace::getValidNamespaces();
}
if ( isset( $value ) && $type == 'submodule' ) {
- $type = $this->getModuleManager()->getNames( $paramName );
+ if ( isset( $paramSettings[self::PARAM_SUBMODULE_MAP] ) ) {
+ $type = array_keys( $paramSettings[self::PARAM_SUBMODULE_MAP] );
+ } else {
+ $type = $this->getModuleManager()->getNames( $paramName );
+ }
}
}
case 'NULL': // nothing to do
break;
case 'string':
+ case 'text':
+ case 'password':
if ( $required && $value === '' ) {
$this->dieUsageMsg( array( 'missingparam', $paramName ) );
}
*/
protected function validateLimit( $paramName, &$value, $min, $max, $botMax = null, $enforceLimits = false ) {
if ( !is_null( $min ) && $value < $min ) {
-
$msg = $this->encodeParamName( $paramName ) . " may not be less than $min (set to $value)";
$this->warnOrDie( $msg, $enforceLimits );
$value = $min;
* @return string Validated and normalized parameter
*/
protected function validateTimestamp( $value, $encParamName ) {
+ // Confusing synonyms for the current time accepted by wfTimestamp()
+ // (wfTimestamp() also accepts various non-strings and the string of 14
+ // ASCII NUL bytes, but those can't get here)
+ if ( !$value ) {
+ $this->logFeatureUsage( 'unclear-"now"-timestamp' );
+ $this->setWarning(
+ "Passing '$value' for timestamp parameter $encParamName has been deprecated." .
+ ' If for some reason you need to explicitly specify the current time without' .
+ ' calculating it client-side, use "now".'
+ );
+ return wfTimestamp( TS_MW );
+ }
+
+ // Explicit synonym for the current time
+ if ( $value === 'now' ) {
+ return wfTimestamp( TS_MW );
+ }
+
$unixTimestamp = wfTimestamp( TS_UNIX, $value );
if ( $unixTimestamp === false ) {
$this->dieUsage(
* Returns the description string for this module
*
* Ignored if an i18n message exists for
- * "apihelp-{$this->getModulePathString()}-description".
+ * "apihelp-{$this->getModulePath()}-description".
*
* @deprecated since 1.25
* @return Message|string|array
*
* For each parameter, ignored if an i18n message exists for the parameter.
* By default that message is
- * "apihelp-{$this->getModulePathString()}-param-{$param}", but it may be
+ * "apihelp-{$this->getModulePath()}-param-{$param}", but it may be
* overridden using ApiBase::PARAM_HELP_MSG in the data returned by
* self::getFinalParams().
*
wfDeprecated( __METHOD__, '1.25' );
$params = $this->getFinalParams( ApiBase::GET_VALUES_FOR_HELP );
if ( $params ) {
-
$paramsDescription = $this->getFinalParamDescription();
$msg = '';
$paramPrefix = "\n" . str_repeat( ' ', 24 );
}
if ( $type === 'submodule' ) {
- $type = $this->getModuleManager()->getNames( $paramName );
+ if ( isset( $paramSettings[self::PARAM_SUBMODULE_MAP] ) ) {
+ $type = array_keys( $paramSettings[self::PARAM_SUBMODULE_MAP] );
+ } else {
+ $type = $this->getModuleManager()->getNames( $paramName );
+ }
sort( $type );
}
if ( is_array( $type ) ) {