r42813 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r42812‎ | r42813 | r42814 >
Date:14:51, 30 October 2008
Author:catrope
Status:old
Tags:
Comment:
API: Tweak r42794 (add docs for ApiBase class constants) a little
Modified paths:
  • /trunk/phase3/includes/api/ApiBase.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/api/ApiBase.php
@@ -38,15 +38,15 @@
3939 */
4040 abstract class ApiBase {
4141
42 - // These constants allow modules to specify exactly how to treat incomming parameters.
 42+ // These constants allow modules to specify exactly how to treat incoming parameters.
4343
4444 const PARAM_DFLT = 0; // Default value of the parameter
45 - const PARAM_ISMULTI = 1; // Boolean, do we accept more than one item for this parameters (ie: titles)
46 - const PARAM_TYPE = 2; // Can be either a string type (ie: 'integer') or an array of allowed values
47 - const PARAM_MAX = 3; // Max value allowed for a parameter
48 - const PARAM_MAX2 = 4; // Max value allowed for a parameter (similar to the upper limits below)
49 - const PARAM_MIN = 5; // Lowest value allowed for a parameter
50 - const PARAM_ALLOW_DUPLICATES = 6;
 45+ const PARAM_ISMULTI = 1; // Boolean, do we accept more than one item for this parameter (e.g.: titles)?
 46+ const PARAM_TYPE = 2; // Can be either a string type (e.g.: 'integer') or an array of allowed values
 47+ const PARAM_MAX = 3; // Max value allowed for a parameter. Only applies if TYPE='integer'
 48+ const PARAM_MAX2 = 4; // Max value allowed for a parameter for bots and sysops. Only applies if TYPE='integer'
 49+ const PARAM_MIN = 5; // Lowest value allowed for a parameter. Only applies if TYPE='integer'
 50+ const PARAM_ALLOW_DUPLICATES = 6; // Boolean, do we allow the same value to be set more than once when ISMULTI=true
5151
5252 const LIMIT_BIG1 = 500; // Fast query, std user limit
5353 const LIMIT_BIG2 = 5000; // Fast query, bot/sysop limit
@@ -147,7 +147,7 @@
148148 /**
149149 * Get the result data array
150150 */
151 - public function & getResultData() {
 151+ public function getResultData() {
152152 return $this->getResult()->getData();
153153 }
154154
@@ -156,20 +156,23 @@
157157 * notice any changes in API.
158158 */
159159 public function setWarning($warning) {
160 - # If there is a warning already, append it to the existing one
161 - $data =& $this->getResult()->getData();
 160+ $data = $this->getResult()->getData();
162161 if(isset($data['warnings'][$this->getModuleName()]))
163162 {
164163 # Don't add duplicate warnings
165164 $warn_regex = preg_quote($warning, '/');
166165 if(preg_match("/{$warn_regex}(\\n|$)/", $data['warnings'][$this->getModuleName()]['*']))
167166 return;
168 - $warning = "{$data['warnings'][$this->getModuleName()]['*']}\n$warning";
169 - unset($data['warnings'][$this->getModuleName()]);
 167+ $oldwarning = $data['warnings'][$this->getModuleName()]['*'];
 168+ # If there is a warning already, append it to the existing one
 169+ $warning = "$oldwarning\n$warning";
 170+ $this->getResult()->unsetValue('warnings', $this->getModuleName());
170171 }
171172 $msg = array();
172173 ApiResult :: setContent($msg, $warning);
 174+ $this->getResult()->disableSizeCheck();
173175 $this->getResult()->addValue('warnings', $this->getModuleName(), $msg);
 176+ $this->getResult()->enableSizeCheck();
174177 }
175178
176179 /**

Follow-up revisions

RevisionCommit summaryAuthorDate
r42821API: Fix r42813, committed some stuff that shouldn't be committed just yetcatrope17:24, 30 October 2008

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r42794Add some docs on these class constantsdemon00:39, 30 October 2008

Status & tagging log