$curRevisionId = 0;
$articleId = 0;
$canonicalSpecialPageName = false; # T23115
+ $services = MediaWikiServices::getInstance();
$title = $this->getTitle();
$ns = $title->getNamespace();
if ( $ns == NS_SPECIAL ) {
list( $canonicalSpecialPageName, /*...*/ ) =
- MediaWikiServices::getInstance()->getSpecialPageFactory()->
+ $services->getSpecialPageFactory()->
resolveAlias( $title->getDBkey() );
} elseif ( $this->canUseWikiPage() ) {
$wikiPage = $this->getWikiPage();
$vars['wgUserNewMsgRevisionId'] = $user->getNewMessageRevisionId();
}
- $contLang = MediaWikiServices::getInstance()->getContentLanguage();
+ $contLang = $services->getContentLanguage();
if ( $contLang->hasVariants() ) {
$vars['wgUserVariant'] = $contLang->getPreferredVariant();
}
* @return DefaultPreferencesFactory
*/
protected static function getDefaultPreferencesFactory() {
+ $services = MediaWikiServices::getInstance();
$authManager = AuthManager::singleton();
- $linkRenderer = MediaWikiServices::getInstance()->getLinkRenderer();
- $config = MediaWikiServices::getInstance()->getMainConfig();
+ $linkRenderer = $services->getLinkRenderer();
+ $config = $services->getMainConfig();
$preferencesFactory = new DefaultPreferencesFactory(
- $config, MediaWikiServices::getInstance()->getContentLanguage(), $authManager,
+ $config, $services->getContentLanguage(), $authManager,
$linkRenderer
);
return $preferencesFactory;
private function processTitlesArray( $titles ) {
$usernames = [];
$linkBatch = new LinkBatch();
+ $services = MediaWikiServices::getInstance();
+ $contLang = $services->getContentLanguage();
foreach ( $titles as $title ) {
if ( is_string( $title ) ) {
$this->mInterwikiTitles[$unconvertedTitle] = $titleObj->getInterwiki();
} else {
// Variants checking
- $contLang = MediaWikiServices::getInstance()->getContentLanguage();
if (
$this->mConvertTitles && $contLang->hasVariants() && !$titleObj->exists()
) {
$this->mAllSpecials[$ns][$dbkey] = $this->mFakePageId;
$target = null;
if ( $ns === NS_SPECIAL && $this->mResolveRedirects ) {
- $spFactory = MediaWikiServices::getInstance()->getSpecialPageFactory();
+ $spFactory = $services->getSpecialPageFactory();
$special = $spFactory->getPage( $dbkey );
if ( $special instanceof RedirectSpecialArticle ) {
// Only RedirectSpecialArticle is intended to redirect to an article, other kinds of
}
}
// Get gender information
- $genderCache = MediaWikiServices::getInstance()->getGenderCache();
+ $genderCache = $services->getGenderCache();
$genderCache->doQuery( $usernames, __METHOD__ );
return $linkBatch;
// If we have more than one engine the list of available sorts is
// difficult to represent. For now don't expose it.
- $alternatives = MediaWiki\MediaWikiServices::getInstance()
+ $services = MediaWiki\MediaWikiServices::getInstance();
+ $alternatives = $services
->getSearchEngineConfig()
->getSearchTypes();
if ( count( $alternatives ) == 1 ) {
$this->allowedParams['sort'] = [
ApiBase::PARAM_DFLT => 'relevance',
- ApiBase::PARAM_TYPE => MediaWiki\MediaWikiServices::getInstance()
+ ApiBase::PARAM_TYPE => $services
->newSearchEngine()
->getValidSorts(),
];
if ( $this->isEmpty() ) {
return false;
}
+ $services = MediaWikiServices::getInstance();
- if ( !MediaWikiServices::getInstance()->getContentLanguage()->needsGenderDistinction() ) {
+ if ( !$services->getContentLanguage()->needsGenderDistinction() ) {
return false;
}
- $genderCache = MediaWikiServices::getInstance()->getGenderCache();
+ $genderCache = $services->getGenderCache();
$genderCache->doLinkBatch( $this->data, $this->caller );
return true;
public static function singleton() {
if ( self::$instance === null ) {
global $wgUseDatabaseMessages, $wgMsgCacheExpiry, $wgUseLocalMessageCache;
+ $services = MediaWikiServices::getInstance();
self::$instance = new self(
- MediaWikiServices::getInstance()->getMainWANObjectCache(),
+ $services->getMainWANObjectCache(),
wfGetMessageCacheStorage(),
$wgUseLocalMessageCache
- ? MediaWikiServices::getInstance()->getLocalServerObjectCache()
+ ? $services->getLocalServerObjectCache()
: new EmptyBagOStuff(),
$wgUseDatabaseMessages,
$wgMsgCacheExpiry,
- MediaWikiServices::getInstance()->getContentLanguage()
+ $services->getContentLanguage()
);
}
global $wgCategoryCollation;
$diffs = array_diff_assoc( $this->mCategories, $existing );
$arr = [];
+ $contLang = MediaWikiServices::getInstance()->getContentLanguage();
+ $collation = Collation::singleton();
foreach ( $diffs as $name => $prefix ) {
$nt = Title::makeTitleSafe( NS_CATEGORY, $name );
- MediaWikiServices::getInstance()->getContentLanguage()->
- findVariantLink( $name, $nt, true );
+ $contLang->findVariantLink( $name, $nt, true );
$type = MWNamespace::getCategoryLinkType( $this->mTitle->getNamespace() );
# things are forced to sort as '*' or something, they'll
# sort properly in the category rather than in page_id
# order or such.
- $sortkey = Collation::singleton()->getSortKey(
- $this->mTitle->getCategorySortkey( $prefix ) );
+ $sortkey = $collation->getSortKey( $this->mTitle->getCategorySortkey( $prefix ) );
$arr[] = [
'cl_from' => $this->mId,
* Perform actual update for the entry
*/
public function doUpdate() {
- $config = MediaWikiServices::getInstance()->getSearchEngineConfig();
+ $services = MediaWikiServices::getInstance();
+ $config = $services->getSearchEngineConfig();
if ( $config->getConfig()->get( 'DisableSearchUpdate' ) || !$this->id ) {
return;
}
- $seFactory = MediaWikiServices::getInstance()->getSearchEngineFactory();
+ $seFactory = $services->getSearchEngineFactory();
foreach ( $config->getSearchTypes() as $type ) {
$search = $seFactory->create( $type );
if ( !$search->supports( 'search-update' ) ) {
* @return string
*/
public function updateText( $text, SearchEngine $se = null ) {
+ $services = MediaWikiServices::getInstance();
+ $contLang = $services->getContentLanguage();
# Language-specific strip/conversion
- $text = MediaWikiServices::getInstance()->getContentLanguage()->normalizeForSearch( $text );
- $se = $se ?: MediaWikiServices::getInstance()->newSearchEngine();
+ $text = $contLang->normalizeForSearch( $text );
+ $se = $se ?: $services->newSearchEngine();
$lc = $se->legalSearchChars() . '&#;';
# Strip HTML markup
$text = preg_replace( "/<\\/?\\s*[A-Za-z][^>]*?>/",
- ' ', MediaWikiServices::getInstance()->getContentLanguage()->lc( " " . $text . " " ) );
+ ' ', $contLang->lc( " " . $text . " " ) );
$text = preg_replace( "/(^|\\n)==\\s*([^\\n]+)\\s*==(\\s)/sD",
"\\1\\2 \\2 \\2\\3", $text ); # Emphasize headings
* @return string A stripped-down title string ready for the search index
*/
private function getNormalizedTitle( SearchEngine $search ) {
+ $contLang = MediaWikiServices::getInstance()->getContentLanguage();
$ns = $this->title->getNamespace();
$title = $this->title->getText();
$lc = $search->legalSearchChars() . '&#;';
- $t = MediaWikiServices::getInstance()->getContentLanguage()->normalizeForSearch( $title );
+ $t = $contLang->normalizeForSearch( $title );
$t = preg_replace( "/[^{$lc}]+/", ' ', $t );
- $t = MediaWikiServices::getInstance()->getContentLanguage()->lc( $t );
+ $t = $contLang->lc( $t );
# Handle 's, s'
$t = preg_replace( "/([{$lc}]+)'s( |$)/", "\\1 \\1's ", $t );
$applyMatchingFiles = function ( ResultWrapper $res, &$searchSet, &$finalFiles )
use ( $fileMatchesSearch, $flags )
{
+ $contLang = MediaWikiServices::getInstance()->getContentLanguage();
$info = $this->getInfo();
foreach ( $res as $row ) {
$file = $this->newFileFromRow( $row );
$dbKeysLook = [ strtr( $file->getName(), ' ', '_' ) ];
if ( !empty( $info['initialCapital'] ) ) {
// Search keys for "hi.png" and "Hi.png" should use the "Hi.png file"
- $dbKeysLook[] = MediaWikiServices::getInstance()->getContentLanguage()->
- lcfirst( $file->getName() );
+ $dbKeysLook[] = $contLang->lcfirst( $file->getName() );
}
foreach ( $dbKeysLook as $dbKey ) {
if ( isset( $searchSet[$dbKey] )
}
function purgeDescriptionPage() {
+ $services = MediaWikiServices::getInstance();
$url = $this->repo->getDescriptionRenderUrl(
- $this->getName(), MediaWikiServices::getInstance()->getContentLanguage()->getCode() );
+ $this->getName(), $services->getContentLanguage()->getCode() );
$key = $this->repo->getLocalCacheKey( 'RemoteFileDescription', 'url', md5( $url ) );
- MediaWikiServices::getInstance()->getMainWANObjectCache()->delete( $key );
+ $services->getMainWANObjectCache()->delete( $key );
}
/**
public function formatParametersForApi() {
$ret = parent::formatParametersForApi();
if ( isset( $ret['details'] ) && is_array( $ret['details'] ) ) {
+ $contLang = MediaWikiServices::getInstance()->getContentLanguage();
foreach ( $ret['details'] as &$detail ) {
if ( isset( $detail['expiry'] ) ) {
- $detail['expiry'] = MediaWikiServices::getInstance()->getContentLanguage()->
+ $detail['expiry'] = $contLang->
formatExpiry( $detail['expiry'], TS_ISO_8601, 'infinite' );
}
}
public function protectDescriptionLog( array $limit, array $expiry ) {
$protectDescriptionLog = '';
+ $dirMark = MediaWikiServices::getInstance()->getContentLanguage()->getDirMark();
foreach ( array_filter( $limit ) as $action => $restrictions ) {
$expiryText = $this->formatExpiry( $expiry[$action] );
$protectDescriptionLog .=
- MediaWikiServices::getInstance()->getContentLanguage()->getDirMark() .
+ $dirMark .
"[$action=$restrictions] ($expiryText)";
}
* @return SearchNearMatcher
*/
protected static function defaultNearMatcher() {
- $config = MediaWikiServices::getInstance()->getMainConfig();
- return MediaWikiServices::getInstance()->newSearchEngine()->getNearMatcher( $config );
+ $services = MediaWikiServices::getInstance();
+ $config = $services->getMainConfig();
+ return $services->newSearchEngine()->getNearMatcher( $config );
}
/**
$notice = $msg->plain();
}
- $cache = MediaWikiServices::getInstance()->getMainWANObjectCache();
+ $services = MediaWikiServices::getInstance();
+ $cache = $services->getMainWANObjectCache();
$parsed = $cache->getWithSetCallback(
// Use the extra hash appender to let eg SSL variants separately cache
// Key is verified with md5 hash of unparsed wikitext
}
);
- $contLang = MediaWikiServices::getInstance()->getContentLanguage();
+ $contLang = $services->getContentLanguage();
return Html::rawElement(
'div',
[
if ( count( $fields ) > 1 && $count > 30 ) {
$this->toc = Linker::tocIndent();
$tocLength = 0;
+ $contLang = MediaWikiServices::getInstance()->getContentLanguage();
foreach ( $fields as $data ) {
# strip out the 'ns' prefix from the section name:
$nsText = ( $ns == NS_MAIN )
? $this->msg( 'blanknamespace' )->escaped()
- : htmlspecialchars( MediaWikiServices::getInstance()->getContentLanguage()->
- getFormattedNsText( $ns ) );
+ : htmlspecialchars( $contLang->getFormattedNsText( $ns ) );
$this->toc .= Linker::tocLine( "editwatchlist-{$data['section']}", $nsText,
$this->getLanguage()->formatNum( ++$tocLength ), 1 ) . Linker::tocLineEnd();
}
);
$linkRenderer = $this->getLinkRenderer();
ksort( $namespaceProtection );
+ $validNamespaces = MWNamespace::getValidNamespaces();
+ $contLang = MediaWikiServices::getInstance()->getContentLanguage();
foreach ( $namespaceProtection as $namespace => $rights ) {
- if ( !in_array( $namespace, MWNamespace::getValidNamespaces() ) ) {
+ if ( !in_array( $namespace, $validNamespaces ) ) {
continue;
}
if ( $namespace == NS_MAIN ) {
$namespaceText = $this->msg( 'blanknamespace' )->text();
} else {
- $namespaceText = MediaWikiServices::getInstance()->getContentLanguage()->
- convertNamespace( $namespace );
+ $namespaceText = $contLang->convertNamespace( $namespace );
}
$out->addHTML(
*/
public function getSearchEngine() {
if ( $this->searchEngine === null ) {
+ $services = MediaWikiServices::getInstance();
$this->searchEngine = $this->searchEngineType ?
- MediaWikiServices::getInstance()->getSearchEngineFactory()->create( $this->searchEngineType ) :
- MediaWikiServices::getInstance()->newSearchEngine();
+ $services->getSearchEngineFactory()->create( $this->searchEngineType ) :
+ $services->newSearchEngine();
}
return $this->searchEngine;
$dbr = $this->getDB();
$user = $this->getUser();
$output = $this->getOutput();
+ $services = MediaWikiServices::getInstance();
# Show a message about replica DB lag, if applicable
- $lag = MediaWikiServices::getInstance()->getDBLoadBalancer()->safeGetLag( $dbr );
+ $lag = $services->getDBLoadBalancer()->safeGetLag( $dbr );
if ( $lag > 0 ) {
$output->showLagWarning( $lag );
}
if ( $this->getConfig()->get( 'RCShowWatchingUsers' )
&& $user->getOption( 'shownumberswatching' )
) {
- $watchedItemStore = MediaWikiServices::getInstance()->getWatchedItemStore();
+ $watchedItemStore = $services->getWatchedItemStore();
}
$s = $list->beginRecentChangesList();
protected function powerSearchBox( $term, array $opts ) {
$rows = [];
$activeNamespaces = $this->specialSearch->getNamespaces();
+ $langConverter = MediaWikiServices::getInstance()->getContentLanguage()->getConverter();
foreach ( $this->searchConfig->searchableNamespaces() as $namespace => $name ) {
$subject = MWNamespace::getSubject( $namespace );
if ( !isset( $rows[$subject] ) ) {
$rows[$subject] = "";
}
- $name = MediaWikiServices::getInstance()->getContentLanguage()->getConverter()->
- convertNamespace( $namespace );
+ $name = $langConverter->convertNamespace( $namespace );
if ( $name === '' ) {
$name = $this->specialSearch->msg( 'blanknamespace' )->text();
}
'rev_id', 'rev_page', 'rev_timestamp', 'rev_user_text', 'rev_comment'
) );
+ $contLang = MediaWikiServices::getInstance()->getContentLanguage();
foreach ( $result as $row ) {
$comment = $commentStore->getComment( 'rev_comment', $row )->text;
- $contLang = MediaWikiServices::getInstance()->getContentLanguage();
if ( $comment !== '' ) {
$comment = '(' . $contLang->truncateForVisual( $comment, 40 ) . ')';
}