From 1b2b5ecde096737d798d20f476f25ad652932a6e Mon Sep 17 00:00:00 2001 From: Roan Kattouw Date: Fri, 18 Jan 2008 16:01:31 +0000 Subject: [PATCH] API: Unifying "the ... parameter must be set" messages into one ('missingparam'), expanding $1 in error codes as well. --- includes/api/ApiBase.php | 8 ++------ includes/api/ApiDelete.php | 4 ++-- includes/api/ApiMove.php | 6 +++--- includes/api/ApiRollback.php | 6 +++--- 4 files changed, 10 insertions(+), 14 deletions(-) diff --git a/includes/api/ApiBase.php b/includes/api/ApiBase.php index da633655d4..74e20d7b67 100644 --- a/includes/api/ApiBase.php +++ b/includes/api/ApiBase.php @@ -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)); } diff --git a/includes/api/ApiDelete.php b/includes/api/ApiDelete.php index 922e58d7ae..635d316210 100644 --- a/includes/api/ApiDelete.php +++ b/includes/api/ApiDelete.php @@ -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) diff --git a/includes/api/ApiMove.php b/includes/api/ApiMove.php index 1ad5d55ed4..2c6146e7f5 100644 --- a/includes/api/ApiMove.php +++ b/includes/api/ApiMove.php @@ -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')); diff --git a/includes/api/ApiRollback.php b/includes/api/ApiRollback.php index 232ff3a52c..9107edf5bc 100644 --- a/includes/api/ApiRollback.php +++ b/includes/api/ApiRollback.php @@ -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) -- 2.20.1