* (bug 11562) Added a user_registration parameter/field to the list=allusers query.
* (bug 11588) Preserve document structure for empty dataset in backlinks query.
* Outputting list of all user preferences rather than having to request them by name
+* (bug 11206) api.php should honor maxlag
=== Languages updated in 1.12 ===
return wfIsWindows()
? 'NUL'
: '/dev/null';
+}
+
+/**
+ * Displays a maxlag error
+ *
+ * @param string $host Server that lags the most
+ * @param int $lag Maxlag (actual)
+ * @param int $maxLag Maxlag (requested)
+ */
+function wfMaxlagError( $host, $lag, $maxLag ) {
+ global $wgShowHostnames;
+ header( 'HTTP/1.1 503 Service Unavailable' );
+ header( 'Retry-After: ' . max( intval( $maxLag ), 5 ) );
+ header( 'X-Database-Lag: ' . intval( $lag ) );
+ header( 'Content-Type: text/plain' );
+ if( $wgShowHostnames ) {
+ echo "Waiting for $host: $lag seconds lagged\n";
+ } else {
+ echo "Waiting for a database server: $lag seconds lagged\n";
+ }
}
\ No newline at end of file
}
function checkMaxLag( $maxLag ) {
- global $wgLoadBalancer, $wgShowHostnames;
+ global $wgLoadBalancer;
list( $host, $lag ) = $wgLoadBalancer->getMaxLag();
if ( $lag > $maxLag ) {
- header( 'HTTP/1.1 503 Service Unavailable' );
- header( 'Retry-After: ' . max( intval( $maxLag ), 5 ) );
- header( 'X-Database-Lag: ' . intval( $lag ) );
- header( 'Content-Type: text/plain' );
- if( $wgShowHostnames ) {
- echo "Waiting for $host: $lag seconds lagged\n";
- } else {
- echo "Waiting for a database server: $lag seconds lagged\n";
- }
+ wfMaxlagError( $host, $lag, $maxLag );
return false;
} else {
return true;
wfDebugDieBacktrace("Internal error in $method: $message");
}
+ /**
+ * Indicates if API needs to check maxlag
+ */
+ public function shouldCheckMaxlag() {
+ return true;
+ }
+
+
/**
* Profiling: total module execution time
*/
$this->dieUsage('', 'help');
}
+ public function shouldCheckMaxlag() {
+ return false;
+ }
+
protected function getDescription() {
return array (
'Display this help screen.'
// Instantiate the module requested by the user
$module = new $this->mModules[$this->mAction] ($this, $this->mAction);
+
+ if( $module->shouldCheckMaxlag() && isset( $params['maxlag'] ) ) {
+ // Check for maxlag
+ global $wgLoadBalancer, $wgShowHostnames;
+ $maxLag = $params['maxlag'];
+ list( $host, $lag ) = $wgLoadBalancer->getMaxLag();
+ if ( $lag > $maxLag ) {
+ if( $wgShowHostnames ) {
+ ApiBase :: dieUsage( "Waiting for $host: $lag seconds lagged", 'maxlag' );
+ } else {
+ ApiBase :: dieUsage( "Waiting for a database server: $lag seconds lagged", 'maxlag' );
+ }
+ return;
+ }
+ }
if (!$this->mInternalMode) {
ApiBase :: PARAM_DFLT => 'help',
ApiBase :: PARAM_TYPE => $this->mModuleNames
),
- 'version' => false
+ 'version' => false,
+ 'maxlag' => array (
+ ApiBase :: PARAM_TYPE => 'integer'
+ ),
);
}
return array (
'format' => 'The format of the output',
'action' => 'What action you would like to perform',
- 'version' => 'When showing help, include version for each module'
+ 'version' => 'When showing help, include version for each module',
+ 'maxlag' => 'Maximum lag'
);
}
$psModule = new ApiPageSet($this);
return $psModule->makeHelpMsgParameters() . parent :: makeHelpMsgParameters();
}
+
+ // @todo should work correctly
+ public function shouldCheckMaxlag() {
+ return true;
+ }
protected function getParamDescription() {
return array (