API: Unifying "the ... parameter must be set" messages into one ('missingparam')...
authorRoan Kattouw <catrope@users.mediawiki.org>
Fri, 18 Jan 2008 16:01:31 +0000 (16:01 +0000)
committerRoan Kattouw <catrope@users.mediawiki.org>
Fri, 18 Jan 2008 16:01:31 +0000 (16:01 +0000)
includes/api/ApiBase.php
includes/api/ApiDelete.php
includes/api/ApiMove.php
includes/api/ApiRollback.php

index da63365..74e20d7 100644 (file)
@@ -595,11 +595,7 @@ abstract class ApiBase {
                // 'badtitletext' => shouldn't happen
                
                // API-specific messages
-               'notitle' => array('code' => 'notitle', 'info' => "The title parameter must be set"),
-               'notoken' => array('code' => 'notoken', 'info' => "The token parameter must be set"),
-               'nouser' => array('code' => 'nouser', 'info' => "The user parameter must be set"),
-               'nofrom' => array('code' => 'nofrom', 'info' => "The from parameter must be set"),
-               'noto' => array('code' => 'noto', 'info' => "The to parameter must be set"),
+               'missingparam' => array('code' => 'no$1', 'info' => "The \$1 parameter must be set"),
                'invalidtitle' => array('code' => 'invalidtitle', 'info' => "Bad title ``\$1''"),
                'invaliduser' => array('code' => 'invaliduser', 'info' => "Invalid username ``\$1''")
        );
@@ -611,7 +607,7 @@ abstract class ApiBase {
        public function dieUsageMsg($error) {
                $key = array_shift($error);
                if(isset(self::$messageMap[$key]))
-                       $this->dieUsage(wfMsgReplaceArgs(self::$messageMap[$key]['info'], $error), self::$messageMap[$key]['code']);
+                       $this->dieUsage(wfMsgReplaceArgs(self::$messageMap[$key]['info'], $error), wfMsgReplaceArgs(self::$messageMap[$key]['code'], $error));
                // If the key isn't present, throw an "unknown error"
                $this->dieUsageMsg(array('unknownerror', $key));
        }
index 922e58d..635d316 100644 (file)
@@ -54,9 +54,9 @@ class ApiDelete extends ApiBase {
                
                $titleObj = NULL;
                if(!isset($params['title']))
-                       $this->dieUsageMsg(array('notitle'));
+                       $this->dieUsageMsg(array('missingparam', 'title'));
                if(!isset($params['token']))
-                       $this->dieUsageMsg(array('notoken'));
+                       $this->dieUsageMsg(array('missingparam', 'token'));
 
                $titleObj = Title::newFromText($params['title']);
                if(!$titleObj)
index 1ad5d55..2c6146e 100644 (file)
@@ -46,11 +46,11 @@ class ApiMove extends ApiBase {
        
                $titleObj = NULL;
                if(!isset($params['from']))
-                       $this->dieUsageMsg(array('nofrom'));
+                       $this->dieUsageMsg(array('missingparam', 'from'));
                if(!isset($params['to']))
-                       $this->dieUsageMsg(array('noto'));
+                       $this->dieUsageMsg(array('missingparam', 'to'));
                if(!isset($params['token']))
-                       $this->dieUsageMsg(array('notoken'));
+                       $this->dieUsageMsg(array('missingparam', 'token'));
                if(!$wgUser->matchEditToken($params['token']))
                        $this->dieUsageMsg(array('sessionfailure'));
 
index 232ff3a..9107edf 100644 (file)
@@ -43,11 +43,11 @@ class ApiRollback extends ApiBase {
                
                $titleObj = NULL;
                if(!isset($params['title']))
-                       $this->dieUsageMsg(array('notitle'));
+                       $this->dieUsageMsg(array('missingparam', 'title'));
                if(!isset($params['user']))
-                       $this->dieUsageMsg(array('nouser'));
+                       $this->dieUsageMsg(array('missingparam', 'user'));
                if(!isset($params['token']))
-                       $this->dieUsageMsg(array('notoken'));
+                       $this->dieUsageMsg(array('missingparam', 'token'));
 
                $titleObj = Title::newFromText($params['title']);
                if(!$titleObj)