Index: trunk/phase3/includes/api/ApiBlock.php |
— | — | @@ -159,14 +159,14 @@ |
160 | 160 | } |
161 | 161 | |
162 | 162 | public function possibleErrors() { |
163 | | - return array ( |
164 | | - $this->parseMsg( array( 'missingparam', 'user' ) ), |
165 | | - $this->parseMsg( array( 'missingparam', 'token' ) ), |
166 | | - $this->parseMsg( array( 'sessionfailure' ) ), |
167 | | - $this->parseMsg( array( 'cantblock' ) ), |
168 | | - $this->parseMsg( array( 'canthide' ) ), |
169 | | - $this->parseMsg( array( 'cantblock-email' ) ), |
170 | | - ); |
| 163 | + return array_merge( parent::possibleErrors(), array( |
| 164 | + array( 'missingparam', 'user' ), |
| 165 | + array( 'missingparam', 'token' ), |
| 166 | + array( 'sessionfailure' ), |
| 167 | + array( 'cantblock' ), |
| 168 | + array( 'canthide' ), |
| 169 | + array( 'cantblock-email' ), |
| 170 | + ) ); |
171 | 171 | } |
172 | 172 | |
173 | 173 | protected function getExamples() { |
Index: trunk/phase3/includes/api/ApiBase.php |
— | — | @@ -968,8 +968,32 @@ |
969 | 969 | * Returns a list of all possible errors returned by the module |
970 | 970 | */ |
971 | 971 | public function possibleErrors() { |
972 | | - return array(); |
| 972 | + $ret = array( array( 'readrequired' ) ); |
| 973 | + |
| 974 | + if ( $this->mustBePosted() ) { |
| 975 | + $ret = array_merge( $ret, array( array( 'code' => 'mustbeposted', 'info' => 'The {$this->mAction} module requires a POST request' ) ) ); |
| 976 | + } |
| 977 | + |
| 978 | + return $ret; |
973 | 979 | } |
| 980 | + |
| 981 | + /** |
| 982 | + * |
| 983 | + */ |
| 984 | + public function parseErrors( $errors ) { |
| 985 | + $ret = array(); |
| 986 | + |
| 987 | + foreach ( $errors as $row ) |
| 988 | + { |
| 989 | + if ( isset( $row['code'] ) && isset( $row['info'] ) ) { |
| 990 | + $ret[] = $row; |
| 991 | + } |
| 992 | + else { |
| 993 | + $ret[] = $this->parseMsg( $row ); |
| 994 | + } |
| 995 | + } |
| 996 | + return $ret; |
| 997 | + } |
974 | 998 | |
975 | 999 | /** |
976 | 1000 | * Profiling: total module execution time |
Index: trunk/phase3/includes/api/ApiParamInfo.php |
— | — | @@ -171,8 +171,9 @@ |
172 | 172 | } |
173 | 173 | $result->setIndexedTagName( $retval['parameters'], 'param' ); |
174 | 174 | |
175 | | - // Errors |
176 | | - $retval['errors'] = $obj->possibleErrors(); |
| 175 | + // Errors |
| 176 | + $retval['errors'] = $this->parseErrors( $obj->possibleErrors() ); |
| 177 | + |
177 | 178 | $result->setIndexedTagName( $retval['errors'], 'error' ); |
178 | 179 | |
179 | 180 | return $retval; |