'feedwatchlist' => 'ApiFeedWatchlist',
'help' => 'ApiHelp',
'paraminfo' => 'ApiParamInfo',
+ 'purge' => 'ApiPurge',
);
private static $WriteModules = array (
'move' => 'ApiMove',
'edit' => 'ApiEditPage',
'emailuser' => 'ApiEmailUser',
+ 'watch' => 'ApiWatch',
+ 'patrol' => 'ApiPatrol',
);
/**
if($wgEnableWriteAPI)
$this->mModules += self::$WriteModules;
- $this->mModuleNames = array_keys($this->mModules); // todo: optimize
+ $this->mModuleNames = array_keys($this->mModules);
$this->mFormats = self :: $Formats;
- $this->mFormatNames = array_keys($this->mFormats); // todo: optimize
+ $this->mFormatNames = array_keys($this->mFormats);
$this->mResult = new ApiResult($this);
$this->mShowVersions = false;
if (!$wgUser->isAllowed('writeapi'))
$this->dieUsage('You\'re not allowed to edit this ' .
'wiki through the API', 'writeapidenied');
+ if (wfReadOnly())
+ $this->dieUsageMsg(array('readonlytext'));
}
/**
try {
$this->executeAction();
} catch (Exception $e) {
+ // Log it
+ if ( $e instanceof MWException ) {
+ wfDebugLog( 'exception', $e->getLogMessage() );
+ }
+
//
// Handle any kind of exception by outputing properly formatted error message.
// If this fails, an unhandled exception should be thrown so that global error
$headerStr = 'MediaWiki-API-Error: ' . $errCode;
if ($e->getCode() === 0)
- header($headerStr, true);
+ header($headerStr);
else
header($headerStr, true, $e->getCode());
if($this->mSquidMaxage == -1)
{
# Nobody called setCacheMaxAge(), use the (s)maxage parameters
- $smaxage = $this->mRequest->getVal('smaxage', 0);
- $maxage = $this->mRequest->getVal('maxage', 0);
+ $smaxage = $this->getParameter('smaxage');
+ $maxage = $this->getParameter('maxage');
}
else
$smaxage = $maxage = $this->mSquidMaxage;
$maxLag = $params['maxlag'];
list( $host, $lag ) = wfGetLB()->getMaxLag();
if ( $lag > $maxLag ) {
+ header( 'Retry-After: ' . max( intval( $maxLag ), 5 ) );
+ header( 'X-Database-Lag: ' . intval( $lag ) );
+ // XXX: should we return a 503 HTTP error code like wfMaxlagError() does?
if( $wgShowHostnames ) {
ApiBase :: dieUsage( "Waiting for $host: $lag seconds lagged", 'maxlag' );
} else {
// Execute
$module->profileIn();
$module->execute();
+ wfRunHooks('APIAfterExecute', array(&$module));
$module->profileOut();
if (!$this->mInternalMode) {
'API developers:',
' Roan Kattouw <Firstname>.<Lastname>@home.nl (lead developer Sep 2007-present)',
' Victor Vasiliev - vasilvv at gee mail dot com',
- ' Bryan Tongh Minh - bryan dot tonghminh at gee mail dot com',
+ ' Bryan Tong Minh - bryan . tongminh @ gmail . com',
' Yuri Astrakhan <Firstname><Lastname>@gmail.com (creator, lead developer Sep 2006-Sep 2007)',
'',
'Please send your comments, suggestions and questions to mediawiki-api@lists.wikimedia.org',
public static function makeHelpMsgHeader($module, $paramName) {
$modulePrefix = $module->getModulePrefix();
- if (!empty($modulePrefix))
+ if (strval($modulePrefix) !== '')
$modulePrefix = "($modulePrefix) ";
return "* $paramName={$module->getModuleName()} $modulePrefix*";