Merge "Messages collected above the form are meant to live as boxed messages"
[lhc/web/wiklou.git] / includes / api / ApiBase.php
index d8134bb..7518008 100644 (file)
@@ -992,7 +992,7 @@ abstract class ApiBase extends ContextSource {
                        return;
                }
 
-               $queryValues = $this->getRequest()->getQueryValues();
+               $queryValues = $this->getRequest()->getQueryValuesOnly();
                $badParams = [];
                foreach ( $params as $param ) {
                        if ( $prefix !== 'noprefix' ) {
@@ -1308,8 +1308,15 @@ abstract class ApiBase extends ContextSource {
                                                }
                                                break;
                                        case 'limit':
+                                               // Must be a number or 'max'
+                                               if ( $value !== 'max' ) {
+                                                       $value = (int)$value;
+                                               }
+                                               if ( $multi ) {
+                                                       self::dieDebug( __METHOD__, "Multi-values not supported for $encParamName" );
+                                               }
                                                if ( !$parseLimit ) {
-                                                       // Don't do any validation whatsoever
+                                                       // Don't do min/max validation and don't parse 'max'
                                                        break;
                                                }
                                                if ( !isset( $paramSettings[self::PARAM_MAX] )
@@ -1320,21 +1327,16 @@ abstract class ApiBase extends ContextSource {
                                                                "MAX1 or MAX2 are not defined for the limit $encParamName"
                                                        );
                                                }
-                                               if ( $multi ) {
-                                                       self::dieDebug( __METHOD__, "Multi-values not supported for $encParamName" );
-                                               }
-                                               $min = $paramSettings[self::PARAM_MIN] ?? 0;
-                                               if ( $value == 'max' ) {
+                                               if ( $value === 'max' ) {
                                                        $value = $this->getMain()->canApiHighLimits()
                                                                ? $paramSettings[self::PARAM_MAX2]
                                                                : $paramSettings[self::PARAM_MAX];
                                                        $this->getResult()->addParsedLimit( $this->getModuleName(), $value );
                                                } else {
-                                                       $value = (int)$value;
                                                        $this->validateLimit(
                                                                $paramName,
                                                                $value,
-                                                               $min,
+                                                               $paramSettings[self::PARAM_MIN] ?? 0,
                                                                $paramSettings[self::PARAM_MAX],
                                                                $paramSettings[self::PARAM_MAX2]
                                                        );
@@ -1583,6 +1585,7 @@ abstract class ApiBase extends ContextSource {
                                'integeroutofrange',
                                [ 'min' => $min, 'max' => $max, 'botMax' => $botMax ?: $max ]
                        );
+                       // @phan-suppress-next-line PhanTypeMismatchArgument
                        $this->warnOrDie( $msg, $enforceLimits );
                        $value = $min;
                }
@@ -1604,6 +1607,7 @@ abstract class ApiBase extends ContextSource {
                                                'integeroutofrange',
                                                [ 'min' => $min, 'max' => $max, 'botMax' => $botMax ?: $max ]
                                        );
+                                       // @phan-suppress-next-line PhanTypeMismatchArgument
                                        $this->warnOrDie( $msg, $enforceLimits );
                                        $value = $botMax;
                                }
@@ -1614,6 +1618,7 @@ abstract class ApiBase extends ContextSource {
                                        'integeroutofrange',
                                        [ 'min' => $min, 'max' => $max, 'botMax' => $botMax ?: $max ]
                                );
+                               // @phan-suppress-next-line PhanTypeMismatchArgument
                                $this->warnOrDie( $msg, $enforceLimits );
                                $value = $max;
                        }
@@ -2020,6 +2025,7 @@ abstract class ApiBase extends ContextSource {
         */
        public function dieWithException( $exception, array $options = [] ) {
                $this->dieWithError(
+                       // @phan-suppress-next-line PhanTypeMismatchArgument
                        $this->getErrorFormatter()->getMessageFromException( $exception, $options )
                );
        }
@@ -2462,6 +2468,7 @@ abstract class ApiBase extends ContextSource {
                                        if ( $m ) {
                                                $m = new ApiHelpParamValueMessage(
                                                        $value,
+                                                       // @phan-suppress-next-line PhanTypeMismatchArgument
                                                        [ $m->getKey(), 'api-help-param-no-description' ],
                                                        $m->getParams(),
                                                        isset( $deprecatedValues[$value] )