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;
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
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 {
public static function makeHelpMsgHeader($module, $paramName) {
$modulePrefix = $module->getModulePrefix();
- if (!empty($modulePrefix))
+ if (strval($modulePrefix) !== '')
$modulePrefix = "($modulePrefix) ";
return "* $paramName={$module->getModuleName()} $modulePrefix*";