Index: branches/wmf/1.16wmf4/includes/api/ApiBase.php |
— | — | @@ -50,6 +50,7 @@ |
51 | 51 | const PARAM_MIN = 5; // Lowest value allowed for a parameter. Only applies if TYPE='integer' |
52 | 52 | const PARAM_ALLOW_DUPLICATES = 6; // Boolean, do we allow the same value to be set more than once when ISMULTI=true |
53 | 53 | const PARAM_DEPRECATED = 7; // Boolean, is the parameter deprecated (will show a warning) |
| 54 | + const PARAM_REQUIRED = 8; // Boolean, is the parameter required? |
54 | 55 | |
55 | 56 | const LIMIT_BIG1 = 500; // Fast query, std user limit |
56 | 57 | const LIMIT_BIG2 = 5000; // Fast query, bot/sysop limit |
— | — | @@ -300,6 +301,12 @@ |
301 | 302 | if ( $deprecated ) { |
302 | 303 | $desc = "DEPRECATED! $desc"; |
303 | 304 | } |
| 305 | + |
| 306 | + $required = isset( $paramSettings[self::PARAM_REQUIRED] ) ? |
| 307 | + $paramSettings[self::PARAM_REQUIRED] : false; |
| 308 | + if ( $required ) { |
| 309 | + $desc .= $paramPrefix . "This parameter is required"; |
| 310 | + } |
304 | 311 | |
305 | 312 | $type = isset( $paramSettings[self::PARAM_TYPE] ) ? $paramSettings[self::PARAM_TYPE] : null; |
306 | 313 | if ( isset( $type ) ) { |
— | — | @@ -565,6 +572,7 @@ |
566 | 573 | $type = isset( $paramSettings[self::PARAM_TYPE] ) ? $paramSettings[self::PARAM_TYPE] : null; |
567 | 574 | $dupes = isset( $paramSettings[self::PARAM_ALLOW_DUPLICATES] ) ? $paramSettings[self::PARAM_ALLOW_DUPLICATES] : false; |
568 | 575 | $deprecated = isset( $paramSettings[self::PARAM_DEPRECATED] ) ? $paramSettings[self::PARAM_DEPRECATED] : false; |
| 576 | + $required = isset( $paramSettings[self::PARAM_REQUIRED] ) ? $paramSettings[self::PARAM_REQUIRED] : false; |
569 | 577 | |
570 | 578 | // When type is not given, and no choices, the type is the same as $default |
571 | 579 | if ( !isset( $type ) ) { |
— | — | @@ -672,6 +680,8 @@ |
673 | 681 | if ( $deprecated && $value !== false ) { |
674 | 682 | $this->setWarning( "The $encParamName parameter has been deprecated." ); |
675 | 683 | } |
| 684 | + } else if ( $required ) { |
| 685 | + $this->dieUsageMsg( array( 'missingparam', $paramName ) ); |
676 | 686 | } |
677 | 687 | |
678 | 688 | return $value; |
Property changes on: branches/wmf/1.16wmf4/includes/api/ApiBase.php |
___________________________________________________________________ |
Modified: svn:mergeinfo |
679 | 689 | Merged /trunk/phase3/includes/api/ApiBase.php:r70460-70462,70477,70479,70554 |