$this->mModulePrefix = $modulePrefix;
if ( !$this->isMain() ) {
- $this->setContext( $this->mMainModule );
+ $this->setContext( $mainModule->getContext() );
}
}
* The object will have the WebRequest and the User object set to the ones
* used in this instance.
*
- * @deprecated 1.19 use getContext to get the current context
- * @return RequestContext
+ * @deprecated since 1.19 use getContext to get the current context
+ * @return DerivativeContext
*/
public function createContext() {
- return $this->getContext();
+ wfDeprecated( __METHOD__, '1.19' );
+ return new DerivativeContext( $this->getContext() );
}
/**
public function makeHelpMsg() {
static $lnPrfx = "\n ";
- $msg = $this->getDescription();
+ $msg = $this->getFinalDescription();
if ( $msg !== false ) {
* Callback for preg_replace_callback() call in makeHelpMsg().
* Replaces a source file name with a link to ViewVC
*
+ * @param $matches array
* @return string
*/
public function makeHelpMsg_callback( $matches ) {
// This is necessary to make stuff like ApiMain::getVersion()
// returning the version string for ApiBase work
if ( $path ) {
- return "{$matches[0]}\n http://svn.wikimedia.org/" .
+ return "{$matches[0]}\n https://svn.wikimedia.org/" .
"viewvc/mediawiki/trunk/" . dirname( $path ) .
"/{$matches[2]}";
}
/**
* Get final list of parameters, after hooks have had a chance to
* tweak it as needed.
+ *
* @return array or false
*/
public function getFinalParams() {
}
/**
- * Get final description, after hooks have had a chance to tweak it as
+ * Get final parameter descriptions, after hooks have had a chance to tweak it as
* needed.
+ *
* @return array
*/
public function getFinalParamDescription() {
return $desc;
}
+ /**
+ * Get final module description, after hooks have had a chance to tweak it as
+ * needed.
+ *
+ * @return array
+ */
+ public function getFinalDescription() {
+ $desc = $this->getDescription();
+ wfRunHooks( 'APIGetDescription', array( &$this, &$desc ) );
+ return $desc;
+ }
+
/**
* This method mangles parameter name based on the prefix supplied to the constructor.
* Override this method to change parameter name during runtime
* @return array
*/
public static function getValidNamespaces() {
+ wfDeprecated( __METHOD__, '1.17' );
return MWNamespace::getValidNamespaces();
}
'mustbeposted' => array( 'code' => 'mustbeposted', 'info' => "The \$1 module requires a POST request" ),
'show' => array( 'code' => 'show', 'info' => 'Incorrect parameter - mutually exclusive values may not be supplied' ),
'specialpage-cantexecute' => array( 'code' => 'specialpage-cantexecute', 'info' => "You don't have permission to view the results of this special page" ),
+ 'invalidoldimage' => array( 'code' => 'invalidoldimage', 'info' => 'The oldimage parameter has invalid format' ),
+ 'nodeleteablefile' => array( 'code' => 'nodeleteablefile', 'info' => 'No such old version of the file' ),
// ApiEditPage messages
'noimageredirect-anon' => array( 'code' => 'noimageredirect-anon', 'info' => "Anonymous users can't create image redirects" ),
'copyuploaddisabled' => array( 'code' => 'copyuploaddisabled', 'info' => 'Uploads by URL is not enabled. Make sure $wgAllowCopyUploads is set to true in LocalSettings.php.' ),
'filename-tooshort' => array( 'code' => 'filename-tooshort', 'info' => 'The filename is too short' ),
+ 'filename-toolong' => array( 'code' => 'filename-toolong', 'info' => 'The filename is too long' ),
'illegal-filename' => array( 'code' => 'illegal-filename', 'info' => 'The filename is not allowed' ),
'filetype-missing' => array( 'code' => 'filetype-missing', 'info' => 'The file is missing an extension' ),
);
public function getWatchlistUser( $params ) {
if ( !is_null( $params['owner'] ) && !is_null( $params['token'] ) ) {
$user = User::newFromName( $params['owner'], false );
- if ( !$user->getId() ) {
+ if ( !($user && $user->getId()) ) {
$this->dieUsage( 'Specified user does not exist', 'bad_wlowner' );
}
$token = $user->getOption( 'watchlisttoken' );
return $this->mDBTime;
}
+ /**
+ * @return DatabaseBase
+ */
+ protected function getDB() {
+ return wfGetDB( DB_SLAVE, 'api' );
+ }
+
/**
* Debugging function that prints a value and an optional backtrace
* @param $value mixed Value to print