Followup r70460/r70461
authorSam Reed <reedy@users.mediawiki.org>
Wed, 4 Aug 2010 20:27:56 +0000 (20:27 +0000)
committerSam Reed <reedy@users.mediawiki.org>
Wed, 4 Aug 2010 20:27:56 +0000 (20:27 +0000)
use self consistently

Fold in duplicate loop

missingparam can be done during attempt to set ParamCache, we might aswell give up and not finish populating the param cache if we're gonna die from a missing param

includes/api/ApiBase.php

index 15a3a89..be1be86 100644 (file)
@@ -496,18 +496,14 @@ abstract class ApiBase {
                                foreach ( $params as $paramName => $paramSettings ) {
                                        $results[$paramName] = $this->getParameterFromSettings( 
                                                $paramName, $paramSettings, $parseLimit );
+
+                                       if( isset( $paramSettings[self::PARAM_REQUIRED] ) && !isset( $results[$paramName] ) ) {
+                                               $this->dieUsageMsg( array( 'missingparam', $paramName ) );
+                                       }
                                }
                        }
                        $this->mParamCache[$parseLimit] = $results;
                }
-               
-               $allparams = $this->getAllowedParams();
-               foreach( $this->mParamCache[$parseLimit] as $param => $val ) {
-                       if( isset( $allparams[$param][ApiBase::PARAM_REQUIRED] ) && !isset( $val ) ) {
-                               $this->dieUsageMsg( array( 'missingparam', $param ) );
-                       }
-               }
-               
                return $this->mParamCache[$parseLimit];
        }