$fit = $this->appendMagicWords( $p );
break;
case 'interwikimap':
- $filteriw = $params['filteriw'] ?? false;
- $fit = $this->appendInterwikiMap( $p, $filteriw );
+ $fit = $this->appendInterwikiMap( $p, $params['filteriw'] );
break;
case 'dbrepllag':
$fit = $this->appendDbReplLagInfo( $p, $params['showalldb'] );
$fit = $this->appendUploadDialog( $p );
break;
default:
- ApiBase::dieDebug( __METHOD__, "Unknown prop=$p" );
+ ApiBase::dieDebug( __METHOD__, "Unknown prop=$p" ); // @codeCoverageIgnore
}
if ( !$fit ) {
// Abuse siprop as a query-continue parameter
}
protected function appendGeneralInfo( $property ) {
- global $wgContLang;
-
$config = $this->getConfig();
$data = [];
$data['phpversion'] = PHP_VERSION;
$data['phpsapi'] = PHP_SAPI;
if ( defined( 'HHVM_VERSION' ) ) {
- $data['hhvmversion'] = HHVM_VERSION;
+ $data['hhvmversion'] = HHVM_VERSION; // @codeCoverageIgnore
}
$data['dbtype'] = $config->get( 'DBtype' );
$data['dbversion'] = $this->getDB()->getServerVersion();
$data['langconversion'] = !$config->get( 'DisableLangConversion' );
$data['titleconversion'] = !$config->get( 'DisableTitleConversion' );
- if ( $wgContLang->linkPrefixExtension() ) {
- $linkPrefixCharset = $wgContLang->linkPrefixCharset();
+ $contLang = MediaWikiServices::getInstance()->getContentLanguage();
+ if ( $contLang->linkPrefixExtension() ) {
+ $linkPrefixCharset = $contLang->linkPrefixCharset();
$data['linkprefixcharset'] = $linkPrefixCharset;
// For backwards compatibility
$data['linkprefix'] = "/^((?>.*[^$linkPrefixCharset]|))(.+)$/sDu";
$data['linkprefix'] = '';
}
- $linktrail = $wgContLang->linkTrail();
+ $linktrail = $contLang->linkTrail();
$data['linktrail'] = $linktrail ?: '';
$data['legaltitlechars'] = Title::legalChars();
$data['lang'] = $config->get( 'LanguageCode' );
$fallbacks = [];
- foreach ( $wgContLang->getFallbackLanguages() as $code ) {
+ foreach ( $contLang->getFallbackLanguages() as $code ) {
$fallbacks[] = [ 'code' => $code ];
}
$data['fallback'] = $fallbacks;
ApiResult::setIndexedTagName( $data['fallback'], 'lang' );
- if ( $wgContLang->hasVariants() ) {
+ if ( $contLang->hasVariants() ) {
$variants = [];
- foreach ( $wgContLang->getVariants() as $code ) {
+ foreach ( $contLang->getVariants() as $code ) {
$variants[] = [
'code' => $code,
- 'name' => $wgContLang->getVariantname( $code ),
+ 'name' => $contLang->getVariantname( $code ),
];
}
$data['variants'] = $variants;
ApiResult::setIndexedTagName( $data['variants'], 'lang' );
}
- $data['rtl'] = $wgContLang->isRTL();
- $data['fallback8bitEncoding'] = $wgContLang->fallback8bitEncoding();
+ $data['rtl'] = $contLang->isRTL();
+ $data['fallback8bitEncoding'] = $contLang->fallback8bitEncoding();
$data['readonly'] = wfReadOnly();
if ( $data['readonly'] ) {
$tz = $config->get( 'Localtimezone' );
$offset = $config->get( 'LocalTZoffset' );
- if ( is_null( $tz ) ) {
- $tz = 'UTC';
- $offset = 0;
- } elseif ( is_null( $offset ) ) {
- $offset = 0;
- }
$data['timezone'] = $tz;
$data['timeoffset'] = intval( $offset );
$data['articlepath'] = $config->get( 'ArticlePath' );
}
protected function appendNamespaces( $property ) {
- global $wgContLang;
$data = [
ApiResult::META_TYPE => 'assoc',
];
- foreach ( $wgContLang->getFormattedNamespaces() as $ns => $title ) {
+ foreach (
+ MediaWikiServices::getInstance()->getContentLanguage()->getFormattedNamespaces()
+ as $ns => $title
+ ) {
$data[$ns] = [
'id' => intval( $ns ),
'case' => MWNamespace::isCapitalized( $ns ) ? 'first-letter' : 'case-sensitive',
}
protected function appendNamespaceAliases( $property ) {
- global $wgContLang;
+ $contLang = MediaWikiServices::getInstance()->getContentLanguage();
$aliases = array_merge( $this->getConfig()->get( 'NamespaceAliases' ),
- $wgContLang->getNamespaceAliases() );
- $namespaces = $wgContLang->getNamespaces();
+ $contLang->getNamespaceAliases() );
+ $namespaces = $contLang->getNamespaces();
$data = [];
foreach ( $aliases as $title => $ns ) {
if ( $namespaces[$ns] == $title ) {
}
protected function appendSpecialPageAliases( $property ) {
- global $wgContLang;
$data = [];
- $aliases = $wgContLang->getSpecialPageAliases();
+ $aliases = MediaWikiServices::getInstance()->getContentLanguage()->getSpecialPageAliases();
foreach ( SpecialPageFactory::getNames() as $specialpage ) {
if ( isset( $aliases[$specialpage] ) ) {
$arr = [ 'realname' => $specialpage, 'aliases' => $aliases[$specialpage] ];
}
protected function appendMagicWords( $property ) {
- global $wgContLang;
$data = [];
- foreach ( $wgContLang->getMagicWords() as $magicword => $aliases ) {
+ foreach (
+ MediaWikiServices::getInstance()->getContentLanguage()->getMagicWords()
+ as $magicword => $aliases
+ ) {
$caseSensitive = array_shift( $aliases );
$arr = [ 'name' => $magicword, 'aliases' => $aliases ];
$arr['case-sensitive'] = (bool)$caseSensitive;
}
protected function appendInterwikiMap( $property, $filter ) {
- $local = null;
if ( $filter === 'local' ) {
$local = 1;
} elseif ( $filter === '!local' ) {
$local = 0;
- } elseif ( $filter ) {
- ApiBase::dieDebug( __METHOD__, "Unknown filter=$filter" );
+ } else {
+ // $filter === null
+ $local = null;
}
$params = $this->extractRequestParams();
$url = $config->get( 'RightsUrl' );
}
$text = $config->get( 'RightsText' );
- if ( !$text && $title ) {
+ if ( $title && !strlen( $text ) ) {
$text = $title->getPrefixedText();
}
$data = [
- 'url' => $url ?: '',
- 'text' => $text ?: ''
+ 'url' => strlen( $url ) ? $url : '',
+ 'text' => strlen( $text ) ? $text : '',
];
return $this->getResult()->addValue( 'query', $property, $data );
public function appendExtensionTags( $property ) {
global $wgParser;
- $wgParser->firstCallInit();
- $tags = array_map( [ $this, 'formatParserTags' ], $wgParser->getTags() );
+ $tags = array_map(
+ function ( $item ) {
+ return "<$item>";
+ },
+ $wgParser->getTags()
+ );
ApiResult::setArrayType( $tags, 'BCarray' );
ApiResult::setIndexedTagName( $tags, 't' );
public function appendFunctionHooks( $property ) {
global $wgParser;
- $wgParser->firstCallInit();
$hooks = $wgParser->getFunctionHooks();
ApiResult::setArrayType( $hooks, 'BCarray' );
ApiResult::setIndexedTagName( $hooks, 'h' );
return $this->getResult()->addValue( 'query', $property, $config );
}
- private function formatParserTags( $item ) {
- return "<{$item}>";
- }
-
public function appendSubscribedHooks( $property ) {
$hooks = $this->getConfig()->get( 'Hooks' );
$myWgHooks = $hooks;