r70479 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r70478‎ | r70479 | r70480 >
Date:21:19, 4 August 2010
Author:reedy
Status:ok
Tags:
Comment:
Further followup to r70460/r70461 and r70477

Move code into getParameterFromSettings, most of the flesh is there anyway (it checks isset( $value ) ), so we can use the else to check if it's required

A followup could be to whinge if '' is returned for a string
Modified paths:
  • /trunk/phase3/includes/api/ApiBase.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/api/ApiBase.php
@@ -496,10 +496,6 @@
497497 foreach ( $params as $paramName => $paramSettings ) {
498498 $results[$paramName] = $this->getParameterFromSettings(
499499 $paramName, $paramSettings, $parseLimit );
500 -
501 - if( isset( $paramSettings[self::PARAM_REQUIRED] ) && !isset( $results[$paramName] ) ) {
502 - $this->dieUsageMsg( array( 'missingparam', $paramName ) );
503 - }
504500 }
505501 }
506502 $this->mParamCache[$parseLimit] = $results;
@@ -627,6 +623,7 @@
628624 $type = isset( $paramSettings[self::PARAM_TYPE] ) ? $paramSettings[self::PARAM_TYPE] : null;
629625 $dupes = isset( $paramSettings[self::PARAM_ALLOW_DUPLICATES] ) ? $paramSettings[self::PARAM_ALLOW_DUPLICATES] : false;
630626 $deprecated = isset( $paramSettings[self::PARAM_DEPRECATED] ) ? $paramSettings[self::PARAM_DEPRECATED] : false;
 627+ $required = isset( $paramSettings[self::PARAM_REQUIRED] ) ? $paramSettings[self::PARAM_REQUIRED] : false;
631628
632629 // When type is not given, and no choices, the type is the same as $default
633630 if ( !isset( $type ) ) {
@@ -745,6 +742,8 @@
746743 if ( $deprecated && $value !== false ) {
747744 $this->setWarning( "The $encParamName parameter has been deprecated." );
748745 }
 746+ } else if ( $required ) {
 747+ $this->dieUsageMsg( array( 'missingparam', $paramName ) );
749748 }
750749
751750 return $value;

Follow-up revisions

RevisionCommit summaryAuthorDate
r70480Followup r70479...reedy21:21, 4 August 2010
r734691.16wmf4: Merging PARAM_REQUIRED support from trunk for upcoming ArticleAsses...catrope18:53, 21 September 2010

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r70460* PARAM_REQUIRED parameter flag added. If this flag is set, and the end user ...soxred9313:35, 4 August 2010
r70461Followup to r70460: Committed wrong version of ApiBase.php, convert all core ...soxred9314:15, 4 August 2010
r70477Followup r70460/r70461...reedy20:27, 4 August 2010

Status & tagging log