Followup to r70460: Committed wrong version of ApiBase.php, convert all core API...
authorX! <soxred93@users.mediawiki.org>
Wed, 4 Aug 2010 14:15:33 +0000 (14:15 +0000)
committerX! <soxred93@users.mediawiki.org>
Wed, 4 Aug 2010 14:15:33 +0000 (14:15 +0000)
13 files changed:
includes/api/ApiBase.php
includes/api/ApiBlock.php
includes/api/ApiEditPage.php
includes/api/ApiEmailUser.php
includes/api/ApiMove.php
includes/api/ApiPatrol.php
includes/api/ApiProtect.php
includes/api/ApiPurge.php
includes/api/ApiQueryBacklinks.php
includes/api/ApiRollback.php
includes/api/ApiUndelete.php
includes/api/ApiUpload.php
includes/api/ApiUserrights.php

index 099d6f5..a1bb693 100644 (file)
@@ -503,7 +503,7 @@ abstract class ApiBase {
                
                $allparams = $this->getAllowedParams();
                foreach( $this->mParamCache[$parseLimit] as $param => $val ) {
-                       if( !isset( $allparams[$param][ApiBase::PARAM_REQUIRED] ) ) {
+                       if( isset( $allparams[$param][ApiBase::PARAM_REQUIRED] ) && !isset( $val ) ) {
                                $this->dieUsageMsg( array( 'missingparam', $param ) );
                        }
                }
index dfd52e5..f597204 100644 (file)
@@ -58,9 +58,6 @@ class ApiBlock extends ApiBase {
                        return;
                }
 
-               if ( is_null( $params['user'] ) ) {
-                       $this->dieUsageMsg( array( 'missingparam', 'user' ) );
-               }
                if ( !$wgUser->isAllowed( 'block' ) ) {
                        $this->dieUsageMsg( array( 'cantblock' ) );
                }
@@ -135,7 +132,10 @@ class ApiBlock extends ApiBase {
 
        public function getAllowedParams() {
                return array(
-                       'user' => null,
+                       'user' => array(
+                               ApiBase::PARAM_TYPE => 'string',
+                               ApiBase::PARAM_REQUIRED => 1
+                       ),
                        'token' => null,
                        'gettoken' => false,
                        'expiry' => 'never',
index fabbd77..90f11f7 100644 (file)
@@ -45,10 +45,6 @@ class ApiEditPage extends ApiBase {
                global $wgUser;
                $params = $this->extractRequestParams();
 
-               if ( is_null( $params['title'] ) ) {
-                       $this->dieUsageMsg( array( 'missingparam', 'title' ) );
-               }
-
                if ( is_null( $params['text'] ) && is_null( $params['appendtext'] ) &&
                                is_null( $params['prependtext'] ) &&
                                $params['undo'] == 0 )
@@ -388,7 +384,10 @@ class ApiEditPage extends ApiBase {
 
        protected function getAllowedParams() {
                return array(
-                       'title' => null,
+                       'title' => array(
+                               ApiBase::PARAM_TYPE => 'string',
+                               ApiBase::PARAM_REQUIRED => 1
+                       ),
                        'section' => null,
                        'text' => null,
                        'token' => null,
index bc3c7a2..ad35c99 100644 (file)
@@ -41,13 +41,6 @@ class ApiEmailUser extends ApiBase {
                global $wgUser;
 
                $params = $this->extractRequestParams();
-               // Check required parameters
-               if ( !isset( $params['target'] ) ) {
-                       $this->dieUsageMsg( array( 'missingparam', 'target' ) );
-               }
-               if ( !isset( $params['text'] ) ) {
-                       $this->dieUsageMsg( array( 'missingparam', 'text' ) );
-               }
 
                // Validate target
                $targetUser = SpecialEmailUser::getTarget( $params['target'] );
@@ -90,9 +83,15 @@ class ApiEmailUser extends ApiBase {
 
        public function getAllowedParams() {
                return array(
-                       'target' => null,
+                       'target' => array(
+                               ApiBase::PARAM_TYPE => 'string',
+                               ApiBase::PARAM_REQUIRED => 1
+                       ),
                        'subject' => null,
-                       'text' => null,
+                       'text' => array(
+                               ApiBase::PARAM_TYPE => 'string',
+                               ApiBase::PARAM_REQUIRED => 1
+                       ),
                        'token' => null,
                        'ccme' => false,
                );
index 9b60171..4c52d3d 100644 (file)
@@ -45,9 +45,6 @@ class ApiMove extends ApiBase {
                }
 
                $this->requireOnlyOneParameter( $params, 'from', 'fromid' );
-               if ( !isset( $params['to'] ) ) {
-                       $this->dieUsageMsg( array( 'missingparam', 'to' ) );
-               }
 
                if ( isset( $params['from'] ) ) {
                        $fromTitle = Title::newFromText( $params['from'] );
@@ -172,7 +169,10 @@ class ApiMove extends ApiBase {
                        'fromid' => array(
                                ApiBase::PARAM_TYPE => 'integer'
                        ),
-                       'to' => null,
+                       'to' => array(
+                               ApiBase::PARAM_TYPE => 'string',
+                               ApiBase::PARAM_REQUIRED => 1
+                       ),
                        'token' => null,
                        'reason' => null,
                        'movetalk' => false,
index 2f248af..33fbe63 100644 (file)
@@ -43,10 +43,6 @@ class ApiPatrol extends ApiBase {
        public function execute() {
                $params = $this->extractRequestParams();
 
-               if ( !isset( $params['rcid'] ) ) {
-                       $this->dieUsageMsg( array( 'missingparam', 'rcid' ) );
-               }
-
                $rc = RecentChange::newFromID( $params['rcid'] );
                if ( !$rc instanceof RecentChange ) {
                        $this->dieUsageMsg( array( 'nosuchrcid', $params['rcid'] ) );
@@ -70,7 +66,8 @@ class ApiPatrol extends ApiBase {
                return array(
                        'token' => null,
                        'rcid' => array(
-                               ApiBase::PARAM_TYPE => 'integer'
+                               ApiBase::PARAM_TYPE => 'integer',
+                               ApiBase::PARAM_REQUIRED => 1
                        ),
                );
        }
index 9bd7824..77c9f6d 100644 (file)
@@ -41,12 +41,6 @@ class ApiProtect extends ApiBase {
                $params = $this->extractRequestParams();
 
                $titleObj = null;
-               if ( !isset( $params['title'] ) ) {
-                       $this->dieUsageMsg( array( 'missingparam', 'title' ) );
-               }
-               if ( empty( $params['protections'] ) ) {
-                       $this->dieUsageMsg( array( 'missingparam', 'protections' ) );
-               }
 
                $titleObj = Title::newFromText( $params['title'] );
                if ( !$titleObj ) {
@@ -149,10 +143,14 @@ class ApiProtect extends ApiBase {
 
        public function getAllowedParams() {
                return array(
-                       'title' => null,
+                       'title' => array(
+                               ApiBase::PARAM_TYPE => 'string',
+                               ApiBase::PARAM_REQUIRED => 1
+                       ),
                        'token' => null,
                        'protections' => array(
-                               ApiBase::PARAM_ISMULTI => true
+                               ApiBase::PARAM_ISMULTI => true,
+                               ApiBase::PARAM_REQUIRED => 1,
                        ),
                        'expiry' => array(
                                ApiBase::PARAM_ISMULTI => true,
index fbcd9c2..7d3b8a7 100644 (file)
@@ -46,9 +46,6 @@ class ApiPurge extends ApiBase {
                if ( !$wgUser->isAllowed( 'purge' ) ) {
                        $this->dieUsageMsg( array( 'cantpurge' ) );
                }
-               if ( !isset( $params['titles'] ) ) {
-                       $this->dieUsageMsg( array( 'missingparam', 'titles' ) );
-               }
                $result = array();
                foreach ( $params['titles'] as $t ) {
                        $r = array();
@@ -86,7 +83,8 @@ class ApiPurge extends ApiBase {
        public function getAllowedParams() {
                return array(
                        'titles' => array(
-                               ApiBase::PARAM_ISMULTI => true
+                               ApiBase::PARAM_ISMULTI => true,
+                               ApiBase::PARAM_REQUIRED => 1
                        )
                );
        }
index 4a15e45..6d22160 100644 (file)
@@ -345,8 +345,6 @@ class ApiQueryBacklinks extends ApiQueryGeneratorBase {
                                } else {
                                        $this->rootTitle = $title;
                                }
-                       } else {
-                               $this->dieUsageMsg( array( 'missingparam', 'title' ) );
                        }
                }
 
@@ -404,7 +402,10 @@ class ApiQueryBacklinks extends ApiQueryGeneratorBase {
 
        public function getAllowedParams() {
                $retval = array(
-                       'title' => null,
+                       'title' => array(
+                               ApiBase::PARAM_TYPE => 'string',
+                               ApiBase::PARAM_REQUIRED => 1
+                       ),
                        'continue' => null,
                        'namespace' => array(
                                ApiBase::PARAM_ISMULTI => true,
index 5f6f5c6..40a88dc 100644 (file)
@@ -77,8 +77,14 @@ class ApiRollback extends ApiBase {
 
        public function getAllowedParams() {
                return array(
-                       'title' => null,
-                       'user' => null,
+                       'title' => array(
+                               ApiBase::PARAM_TYPE => 'string',
+                               ApiBase::PARAM_REQUIRED => 1
+                       ),
+                       'user' => array(
+                               ApiBase::PARAM_TYPE => 'string',
+                               ApiBase::PARAM_REQUIRED => 1
+                       ),
                        'token' => null,
                        'summary' => null,
                        'markbot' => false,
@@ -133,10 +139,6 @@ class ApiRollback extends ApiBase {
 
                $params = $this->extractRequestParams();
 
-               if ( !isset( $params['user'] ) ) {
-                       $this->dieUsageMsg( array( 'missingparam', 'user' ) );
-               }
-
                // We need to be able to revert IPs, but getCanonicalName rejects them
                $this->mUser = User::isIP( $params['user'] )
                        ? $params['user']
@@ -154,9 +156,6 @@ class ApiRollback extends ApiBase {
                }
 
                $params = $this->extractRequestParams();
-               if ( !isset( $params['title'] ) ) {
-                       $this->dieUsageMsg( array( 'missingparam', 'title' ) );
-               }
 
                $this->mTitleObj = Title::newFromText( $params['title'] );
 
index 89f4a71..6082ef0 100644 (file)
@@ -41,9 +41,6 @@ class ApiUndelete extends ApiBase {
                $params = $this->extractRequestParams();
 
                $titleObj = null;
-               if ( !isset( $params['title'] ) ) {
-                       $this->dieUsageMsg( array( 'missingparam', 'title' ) );
-               }
 
                if ( !$wgUser->isAllowed( 'undelete' ) ) {
                        $this->dieUsageMsg( array( 'permdenied-undelete' ) );
@@ -101,7 +98,10 @@ class ApiUndelete extends ApiBase {
 
        public function getAllowedParams() {
                return array(
-                       'title' => null,
+                       'title' => array(
+                               ApiBase::PARAM_TYPE => 'string',
+                               ApiBase::PARAM_REQUIRED => 1
+                       ),
                        'token' => null,
                        'reason' => '',
                        'timestamps' => array(
index c5ea2f7..8636fea 100644 (file)
@@ -101,10 +101,6 @@ class ApiUpload extends ApiBase {
                // One and only one of the following parameters is needed
                $this->requireOnlyOneParameter( $this->mParams,
                        'sessionkey', 'file', 'url' );
-               // And this one is needed
-               if ( !isset( $this->mParams['filename'] ) ) {
-                       $this->dieUsageMsg( array( 'missingparam', 'filename' ) );
-               }
 
                if ( $this->mParams['sessionkey'] ) {
                        // Upload stashed in a previous request
@@ -318,7 +314,10 @@ class ApiUpload extends ApiBase {
 
        public function getAllowedParams() {
                $params = array(
-                       'filename' => null,
+                       'filename' => array(
+                               ApiBase::PARAM_TYPE => 'string',
+                               ApiBase::PARAM_REQUIRED => 1
+                       ),
                        'comment' => array(
                                ApiBase::PARAM_DFLT => ''
                        ),
index 8f6f659..2869976 100644 (file)
@@ -61,9 +61,6 @@ class ApiUserrights extends ApiBase {
                }
 
                $params = $this->extractRequestParams();
-               if ( is_null( $params['user'] ) ) {
-                       $this->dieUsageMsg( array( 'missingparam', 'user' ) );
-               }
 
                $form = new UserrightsPage;
                $status = $form->fetchUser( $params['user'] );
@@ -88,7 +85,10 @@ class ApiUserrights extends ApiBase {
 
        public function getAllowedParams() {
                return array (
-                       'user' => null,
+                       'user' => array(
+                               ApiBase::PARAM_TYPE => 'string',
+                               ApiBase::PARAM_REQUIRED => 1
+                       ),
                        'add' => array(
                                ApiBase::PARAM_TYPE => User::getAllGroups(),
                                ApiBase::PARAM_ISMULTI => true