* The class functions are divided into several areas of functionality:
*
* Module parameters: Derived classes can define getAllowedParams() to specify
- * which parameters to expect, how to parse and validate them.
+ * which parameters to expect, how to parse and validate them.
*
* Profiling: various methods to allow keeping tabs on various tasks and their
- * time costs
+ * time costs
*
* Self-documentation: code to allow the API to document its own state
*
*/
public function getVersion() {
wfDeprecated( __METHOD__, '1.21' );
+
return '';
}
if ( $this->isMain() ) {
ApiBase::dieDebug( __METHOD__, 'base method was called on main module. ' );
}
+
return $this->getMain()->getResult();
}
*/
public function createContext() {
wfDeprecated( __METHOD__, '1.19' );
+
return new DerivativeContext( $this->getContext() );
}
$msg .= "\nThis module only accepts POST requests";
}
if ( $this->isReadMode() || $this->isWriteMode() ||
- $this->mustBePosted() ) {
+ $this->mustBePosted()
+ ) {
$msg .= "\n";
}
$msg = ' ';
}
$msg .= implode( $prefix, $input ) . "\n";
+
return $msg;
}
+
return '';
}
$isArray = is_array( $type );
if ( !$isArray
- || $isArray && count( $type ) > self::LIMIT_SML1 ) {
+ || $isArray && count( $type ) > self::LIMIT_SML1
+ ) {
$desc .= $paramPrefix . "Maximum number of values " .
- self::LIMIT_SML1 . " (" . self::LIMIT_SML2 . " for bots)";
+ self::LIMIT_SML1 . " (" . self::LIMIT_SML2 . " for bots)";
}
}
}
$msg .= sprintf( " %-19s - %s\n", $this->encodeParamName( $paramName ), $desc );
}
- return $msg;
+ return $msg;
} else {
return false;
}
public function getFinalParams( $flags = 0 ) {
$params = $this->getAllowedParams( $flags );
wfRunHooks( 'APIGetAllowedParams', array( &$this, &$params, $flags ) );
+
return $params;
}
public function getFinalParamDescription() {
$desc = $this->getParamDescription();
wfRunHooks( 'APIGetParamDescription', array( &$this, &$desc ) );
+
return $desc;
}
public function getFinalResultProperties() {
$properties = $this->getResultProperties();
wfRunHooks( 'APIGetResultProperties', array( $this, &$properties ) );
+
return $properties;
}
public function getFinalDescription() {
$desc = $this->getDescription();
wfRunHooks( 'APIGetDescription', array( &$this, &$desc ) );
+
return $desc;
}
}
$this->mParamCache[$parseLimit] = $results;
}
+
return $this->mParamCache[$parseLimit];
}
protected function getParameter( $paramName, $parseLimit = true ) {
$params = $this->getFinalParams();
$paramSettings = $params[$paramName];
+
return $this->getParameterFromSettings( $paramName, $paramSettings, $parseLimit );
}
*/
public static function getValidNamespaces() {
wfDeprecated( __METHOD__, '1.17' );
+
return MWNamespace::getValidNamespaces();
}
* @param string $watchlist Valid values: 'watch', 'unwatch', 'preferences', 'nochange'
* @param $titleObj Title the page under consideration
* @param string $userOption The user option to consider when $watchlist=preferences.
- * If not set will use watchdefault always and watchcreations if $titleObj doesn't exist.
+ * If not set will use watchdefault always and watchcreations if $titleObj doesn't exist.
* @return bool
*/
protected function getWatchlistValue( $watchlist, $titleObj, $userOption = null ) {
return $this->getUser()->getBoolOption( 'watchdefault' ) ||
$this->getUser()->getBoolOption( 'watchcreations' ) && !$titleObj->exists();
}
+
# Watch the article based on the user preference
return $this->getUser()->getBoolOption( $userOption );
$min = isset( $paramSettings[self::PARAM_MIN] ) ? $paramSettings[self::PARAM_MIN] : null;
$max = isset( $paramSettings[self::PARAM_MAX] ) ? $paramSettings[self::PARAM_MAX] : null;
$enforceLimits = isset( $paramSettings[self::PARAM_RANGE_ENFORCE] )
- ? $paramSettings[self::PARAM_RANGE_ENFORCE] : false;
+ ? $paramSettings[self::PARAM_RANGE_ENFORCE] : false;
if ( is_array( $value ) ) {
$value = array_map( 'intval', $value );
// This is a bit awkward, but we want to avoid calling canApiHighLimits() because it unstubs $wgUser
$valuesList = explode( '|', $value, self::LIMIT_SML2 + 1 );
$sizeLimit = count( $valuesList ) > self::LIMIT_SML1 && $this->mMainModule->canApiHighLimits() ?
- self::LIMIT_SML2 : self::LIMIT_SML1;
+ self::LIMIT_SML2 : self::LIMIT_SML1;
if ( self::truncateArray( $valuesList, $sizeLimit ) ) {
$this->setWarning( "Too many values supplied for parameter '$valueName': the limit is $sizeLimit" );
if ( $unixTimestamp === false ) {
$this->dieUsage( "Invalid value '$value' for timestamp parameter $encParamName", "badtimestamp_{$encParamName}" );
}
+
return wfTimestamp( TS_MW, $unixTimestamp );
}
if ( $title === null ) {
$this->dieUsage( "Invalid value '$value' for user parameter $encParamName", "baduser_{$encParamName}" );
}
+
return $title->getText();
}
array_pop( $arr );
$modified = true;
}
+
return $modified;
}
public function isReadMode() {
return true;
}
+
/**
* Indicates whether this module requires write mode
* @return bool
}
$user = $this->getUser();
}
+
return $user;
}
public function getFinalPossibleErrors() {
$possibleErrors = $this->getPossibleErrors();
wfRunHooks( 'APIGetPossibleErrors', array( $this, &$possibleErrors ) );
+
return $possibleErrors;
}
$ret[] = $this->parseMsg( $row );
}
}
+
return $ret;
}
if ( $this->mTimeIn !== 0 ) {
ApiBase::dieDebug( __METHOD__, 'called without calling profileOut() first' );
}
+
return $this->mModuleTime;
}
if ( $this->mDBTimeIn !== 0 ) {
ApiBase::dieDebug( __METHOD__, 'called without calling profileDBOut() first' );
}
+
return $this->mDBTime;
}
$this->mSlaveDB = wfGetDB( DB_SLAVE, 'api' );
$this->profileDBOut();
}
+
return $this->mSlaveDB;
}