From: Sam Reed Date: Thu, 11 Feb 2010 01:13:45 +0000 (+0000) Subject: Start implementation of bug 18771 - List possible errors in action=paraminfo X-Git-Tag: 1.31.0-rc.0~37828 X-Git-Url: http://git.cyclocoop.org/%22%2C%20generer_url_ecrire%28?a=commitdiff_plain;h=ee604825469c58ea9d25680682a5a38a55d0e143;p=lhc%2Fweb%2Fwiklou.git Start implementation of bug 18771 - List possible errors in action=paraminfo Base has empty array() returning method, ApiBlock has implementation of possibleErrors from code above (possibly not complete) Can be finished incrementally, so serves as a review point for Roan --- diff --git a/includes/api/ApiBase.php b/includes/api/ApiBase.php index de5b72cc66..e11e615688 100644 --- a/includes/api/ApiBase.php +++ b/includes/api/ApiBase.php @@ -964,6 +964,12 @@ abstract class ApiBase { return false; } + /** + * Returns a list of all possible errors returned by the module + */ + public function possibleErrors() { + return array(); + } /** * Profiling: total module execution time diff --git a/includes/api/ApiBlock.php b/includes/api/ApiBlock.php index c47e179251..c061656b38 100644 --- a/includes/api/ApiBlock.php +++ b/includes/api/ApiBlock.php @@ -157,6 +157,17 @@ class ApiBlock extends ApiBase { 'Block a user.' ); } + + public function possibleErrors() { + return array ( + $this->parseMsg( array( 'missingparam', 'user' ) ), + $this->parseMsg( array( 'missingparam', 'token' ) ), + $this->parseMsg( array( 'sessionfailure' ) ), + $this->parseMsg( array( 'cantblock' ) ), + $this->parseMsg( array( 'canthide' ) ), + $this->parseMsg( array( 'cantblock-email' ) ), + ); + } protected function getExamples() { return array ( diff --git a/includes/api/ApiParamInfo.php b/includes/api/ApiParamInfo.php index bebc84701f..719fb55799 100644 --- a/includes/api/ApiParamInfo.php +++ b/includes/api/ApiParamInfo.php @@ -96,6 +96,7 @@ class ApiParamInfo extends ApiBase { $retval['description'] = implode( "\n", (array)$obj->getDescription() ); $retval['version'] = implode( "\n", (array)$obj->getVersion() ); $retval['prefix'] = $obj->getModulePrefix(); + if ( $obj->isReadMode() ) $retval['readrights'] = ''; if ( $obj->isWriteMode() ) @@ -104,9 +105,11 @@ class ApiParamInfo extends ApiBase { $retval['mustbeposted'] = ''; if ( $obj instanceof ApiQueryGeneratorBase ) $retval['generator'] = ''; + $allowedParams = $obj->getFinalParams(); if ( !is_array( $allowedParams ) ) return $retval; + $retval['parameters'] = array(); $paramDesc = $obj->getFinalParamDescription(); foreach ( $allowedParams as $n => $p ) @@ -167,6 +170,11 @@ class ApiParamInfo extends ApiBase { $retval['parameters'][] = $a; } $result->setIndexedTagName( $retval['parameters'], 'param' ); + + // Errors + $retval['errors'] = $obj->possibleErrors(); + $result->setIndexedTagName( $retval['errors'], 'error' ); + return $retval; }