case 'dbrepllag' :
$this->appendDbReplLagInfo($p, $params['showalldb']);
break;
+ case 'statistics' :
+ $this->appendStatistics($p);
+ break;
}
}
}
protected function appendGeneralInfo($property) {
- global $wgSitename, $wgVersion, $wgCapitalLinks, $wgRightsCode, $wgRightsText, $wgLanguageCode;
+ global $wgSitename, $wgVersion, $wgCapitalLinks, $wgRightsCode, $wgRightsText, $wgLanguageCode, $IP;
$data = array ();
$mainPage = Title :: newFromText(wfMsgForContent('mainpage'));
$data['base'] = $mainPage->getFullUrl();
$data['sitename'] = $wgSitename;
$data['generator'] = "MediaWiki $wgVersion";
+
+ $svn = SpecialVersion::getSvnRevision ( $IP );
+ if ( $svn ) $data['rev'] = $svn;
+
$data['case'] = $wgCapitalLinks ? 'first-letter' : 'case-sensitive'; // 'case-insensitive' option is reserved for future
if (isset($wgRightsCode))
$data['rightscode'] = $wgRightsCode;
protected function appendInterwikiMap($property, $filter) {
+ $this->resetQueryParams();
$this->addTables('interwiki');
$this->addFields(array('iw_prefix', 'iw_local', 'iw_url'));
- if($filter === 'local')
+ if($filter === 'local') {
$this->addWhere('iw_local = 1');
- else if($filter === '!local')
+ } elseif($filter === '!local') {
$this->addWhere('iw_local = 0');
- else if($filter !== false)
+ } elseif($filter !== false) {
ApiBase :: dieDebug(__METHOD__, "Unknown filter=$filter");
+ }
$this->addOption('ORDER BY', 'iw_prefix');
}
protected function appendDbReplLagInfo($property, $includeAll) {
- global $wgLoadBalancer;
+ global $wgLoadBalancer, $wgShowHostnames;
$data = array();
if ($includeAll) {
+ if (!$wgShowHostnames)
+ $this->dieUsage('Cannot view all servers info unless $wgShowHostnames is true', 'includeAllDenied');
+
global $wgDBservers;
$lags = $wgLoadBalancer->getLagTimes();
foreach( $lags as $i => $lag ) {
} else {
list( $host, $lag ) = $wgLoadBalancer->getMaxLag();
$data[] = array (
- 'host' => $host,
+ 'host' => $wgShowHostnames ? $host : '',
'lag' => $lag);
}
$result->addValue('query', $property, $data);
}
+ protected function appendStatistics($property) {
+ $data = array ();
+ $data['pages'] = intval(SiteStats::pages());
+ $data['articles'] = intval(SiteStats::articles());
+ $data['views'] = intval(SiteStats::views());
+ $data['edits'] = intval(SiteStats::edits());
+ $data['images'] = intval(SiteStats::images());
+ $data['users'] = intval(SiteStats::users());
+ $data['admins'] = intval(SiteStats::admins());
+ $data['jobs'] = intval(SiteStats::jobs());
+ $this->getResult()->addValue('query', $property, $data);
+ }
+
protected function getAllowedParams() {
return array (
'namespaces',
'interwikimap',
'dbrepllag',
+ 'statistics',
)),
'filteriw' => array (
'Which sysinfo properties to get:',
' "general" - Overall system information',
' "namespaces" - List of registered namespaces (localized)',
- ' "interwikimap" - Return interwiki map (optionally filtered)',
- ' "dbrepllag" - Returns DB server with the highest replication lag',
+ ' "statistics" - Returns site statistics',
+ ' "interwikimap" - Returns interwiki map (optionally filtered)',
+ ' "dbrepllag" - Returns database server with the highest replication lag',
),
'filteriw' => 'Return only local or only nonlocal entries of the interwiki map',
- 'showalldb' => 'List all DB servers, not just the one lagging the most',
+ 'showalldb' => 'List all database servers, not just the one lagging the most',
);
}
protected function getExamples() {
return array(
- 'api.php?action=query&meta=siteinfo&siprop=general|namespaces',
+ 'api.php?action=query&meta=siteinfo&siprop=general|namespaces|statistics',
'api.php?action=query&meta=siteinfo&siprop=interwikimap&sifilteriw=local',
'api.php?action=query&meta=siteinfo&siprop=dbrepllag&sishowalldb',
);
return __CLASS__ . ': $Id$';
}
}
-