r62328 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r62327‎ | r62328 | r62329 >
Date:21:34, 11 February 2010
Author:reedy
Status:ok (Comments)
Tags:
Comment:
More of bug 18771 - List possible errors in action=paraminfo

Followup to comments of r62282
Modified paths:
  • /trunk/phase3/includes/api/ApiBase.php (modified) (history)
  • /trunk/phase3/includes/api/ApiBlock.php (modified) (history)
  • /trunk/phase3/includes/api/ApiParamInfo.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/api/ApiBlock.php
@@ -159,14 +159,14 @@
160160 }
161161
162162 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+ ) );
171171 }
172172
173173 protected function getExamples() {
Index: trunk/phase3/includes/api/ApiBase.php
@@ -968,8 +968,32 @@
969969 * Returns a list of all possible errors returned by the module
970970 */
971971 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;
973979 }
 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+ }
974998
975999 /**
9761000 * Profiling: total module execution time
Index: trunk/phase3/includes/api/ApiParamInfo.php
@@ -171,8 +171,9 @@
172172 }
173173 $result->setIndexedTagName( $retval['parameters'], 'param' );
174174
175 - // Errors
176 - $retval['errors'] = $obj->possibleErrors();
 175+ // Errors
 176+ $retval['errors'] = $this->parseErrors( $obj->possibleErrors() );
 177+
177178 $result->setIndexedTagName( $retval['errors'], 'error' );
178179
179180 return $retval;

Follow-up revisions

RevisionCommit summaryAuthorDate
r62331Followup to bryans comment for r62328...reedy21:53, 11 February 2010
r62480* (bug 18771) List possible errors in action=paraminfo...reedy21:36, 14 February 2010

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r62282Start implementation of bug 18771 - List possible errors in action=paraminfo...reedy01:13, 11 February 2010

Comments

#Comment by Bryan (talk | contribs)   21:43, 11 February 2010

ApiBase::parseErrors needs documentation on functionality, expected input and output.

#Comment by Reedy (talk | contribs)   22:10, 11 February 2010

Status & tagging log