From d2d950d256e6ac9e7ddcc117da9b262384204194 Mon Sep 17 00:00:00 2001 From: Sam Reed Date: Sat, 13 Feb 2010 00:09:05 +0000 Subject: [PATCH] Start of blanket coverage of dieUsageMsg in getPossibleErrors Only basic ones done. Couple of other modules done manually --- includes/api/ApiEmailUser.php | 9 +++++++++ includes/api/ApiFormatXml.php | 1 - includes/api/ApiLogin.php | 15 +++++++++++++++ includes/api/ApiMain.php | 6 ++++++ includes/api/ApiPurge.php | 7 +++++++ includes/api/ApiQuerySiteinfo.php | 6 ++++++ includes/api/ApiUnblock.php | 10 ++++++++++ includes/api/ApiUpload.php | 15 +++++++++++++++ includes/api/ApiUserrights.php | 8 ++++++++ 9 files changed, 76 insertions(+), 1 deletion(-) diff --git a/includes/api/ApiEmailUser.php b/includes/api/ApiEmailUser.php index 469fe37b82..12abc26786 100644 --- a/includes/api/ApiEmailUser.php +++ b/includes/api/ApiEmailUser.php @@ -103,6 +103,15 @@ class ApiEmailUser extends ApiBase { 'Email a user.' ); } + + public function getPossibleErrors() { + return array_merge( parent::getPossibleErrors(), array( + array( 'usermaildisabled' ), + array( 'missingparam', 'target' ), + array( 'missingparam', 'text' ), + array( 'missingparam', 'token' ), + ) ); + } protected function getExamples() { return array ( diff --git a/includes/api/ApiFormatXml.php b/includes/api/ApiFormatXml.php index f4342a4744..413e4a4f4f 100644 --- a/includes/api/ApiFormatXml.php +++ b/includes/api/ApiFormatXml.php @@ -190,7 +190,6 @@ class ApiFormatXml extends ApiFormatBase { ); } - public function getDescription() { return 'Output data in XML format' . parent :: getDescription(); } diff --git a/includes/api/ApiLogin.php b/includes/api/ApiLogin.php index 66f843d0fe..720fcb8a76 100644 --- a/includes/api/ApiLogin.php +++ b/includes/api/ApiLogin.php @@ -167,6 +167,21 @@ class ApiLogin extends ApiBase { 'This is to prevent password guessing by automated password crackers.' ); } + + public function getPossibleErrors() { + return array_merge( parent::getPossibleErrors(), array ( + array( 'code' => 'NoName', 'info' => 'You didn\'t set the lgname parameter' ), + array( 'code' => 'Illegal', 'info' => ' You provided an illegal username' ), + array( 'code' => 'NotExists', 'info' => ' The username you provided doesn\'t exist' ), + array( 'code' => 'EmptyPass', 'info' => ' You didn\'t set the lgpassword parameter or you left it empty' ), + array( 'code' => 'WrongPass', 'info' => ' The password you provided is incorrect' ), + array( 'code' => 'WrongPluginPass', 'info' => 'Same as `WrongPass", returned when an authentication plugin rather than MediaWiki itself rejected the password' ), + array( 'code' => 'CreateBlocked', 'info' => 'The wiki tried to automatically create a new account for you, but your IP address has been blocked from account creation' ), + array( 'code' => 'Throttled', 'info' => 'You\'ve logged in too many times in a short time' ), + array( 'code' => 'Blocked', 'info' => 'User is blocked' ), + ) ); +; + } protected function getExamples() { return array( diff --git a/includes/api/ApiMain.php b/includes/api/ApiMain.php index ad010f14f6..2a48f7786a 100644 --- a/includes/api/ApiMain.php +++ b/includes/api/ApiMain.php @@ -539,6 +539,12 @@ class ApiMain extends ApiBase { '', ); } + + public function getPossibleErrors() { + return array_merge( parent::getPossibleErrors(), array( + array( 'readonlytext' ), + ) ); + } /** * Returns an array of strings with credits for the API diff --git a/includes/api/ApiPurge.php b/includes/api/ApiPurge.php index aa6bc4142c..6bcecc773d 100644 --- a/includes/api/ApiPurge.php +++ b/includes/api/ApiPurge.php @@ -102,6 +102,13 @@ class ApiPurge extends ApiBase { 'Purge the cache for the given titles.' ); } + + public function getPossibleErrors() { + return array_merge( parent::getPossibleErrors(), array( + array( 'cantpurge' ), + array( 'missingparam', 'titles' ), + ) ); + } protected function getExamples() { return array( diff --git a/includes/api/ApiQuerySiteinfo.php b/includes/api/ApiQuerySiteinfo.php index 415739e0da..0d35742921 100644 --- a/includes/api/ApiQuerySiteinfo.php +++ b/includes/api/ApiQuerySiteinfo.php @@ -482,6 +482,12 @@ class ApiQuerySiteinfo extends ApiQueryBase { return 'Return general information about the site.'; } + public function getPossibleErrors() { + return array_merge( parent::getPossibleErrors(), array( + array( 'code' => 'includeAllDenied', 'info' => 'Cannot view all servers info unless $wgShowHostnames is true', ), + ) ); + } + protected function getExamples() { return array( 'api.php?action=query&meta=siteinfo&siprop=general|namespaces|namespacealiases|statistics', diff --git a/includes/api/ApiUnblock.php b/includes/api/ApiUnblock.php index b501eb03c2..386dcbcc5a 100644 --- a/includes/api/ApiUnblock.php +++ b/includes/api/ApiUnblock.php @@ -108,6 +108,16 @@ class ApiUnblock extends ApiBase { 'Unblock a user.' ); } + + public function getPossibleErrors() { + return array_merge( parent::getPossibleErrors(), array( + array( 'unblock-notarget' ), + array( 'unblock-idanduser' ), + array( 'missingparam', 'token' ), + array( 'sessionfailure' ), + array( 'cantunblock' ), + ) ); + } protected function getExamples() { return array ( diff --git a/includes/api/ApiUpload.php b/includes/api/ApiUpload.php index c995326d0c..2d8f739527 100644 --- a/includes/api/ApiUpload.php +++ b/includes/api/ApiUpload.php @@ -326,6 +326,21 @@ class ApiUpload extends ApiBase { 'log out and then log back in). Also you must get and send an edit token before doing any upload stuff.' ); } + + public function getPossibleErrors() { + return array_merge( parent::getPossibleErrors(), array( + array( 'uploaddisabled' ), + array( 'missingparam', 'token' ), + array( 'sessionfailure' ), + array( 'invalid-session-key' ), + array( 'uploaddisabled' ), + array( 'badaccess-groups' ), + array( 'missingparam', 'filename' ), + array( 'mustbeloggedin', 'upload' ), + array( 'badaccess-groups' ), + array( 'badaccess-groups' ), + ) ); + } protected function getExamples() { return array( diff --git a/includes/api/ApiUserrights.php b/includes/api/ApiUserrights.php index a8ccb3224c..e5ffe4ec07 100644 --- a/includes/api/ApiUserrights.php +++ b/includes/api/ApiUserrights.php @@ -105,6 +105,14 @@ class ApiUserrights extends ApiBase { 'Add/remove a user to/from groups', ); } + + public function getPossibleErrors() { + return array_merge( parent::getPossibleErrors(), array( + array( 'missingparam', 'user' ), + array( 'missingparam', 'token' ), + array( 'sessionfailure' ), + ) ); + } protected function getExamples() { return array ( -- 2.20.1