use GlobalVarConfig;
use Hooks;
use LBFactory;
+use LinkCache;
use Liuggio\StatsdClient\Factory\StatsdDataFactory;
use LoadBalancer;
use MediaWiki\Services\ServiceContainer;
public function getGenderCache() {
return $this->getService( 'GenderCache' );
}
+
+ /**
+ * @since 1.28
+ * @return LinkCache
+ */
+ public function getLinkCache() {
+ return $this->getService( 'LinkCache' );
+ }
+
/**
* @since 1.28
* @return TitleFormatter
return $store;
},
+ 'LinkCache' => function( MediaWikiServices $services ) {
+ return new LinkCache(
+ $services->getTitleFormatter()
+ );
+ },
+
'GenderCache' => function( MediaWikiServices $services ) {
return new GenderCache();
},
* Get an instance of this class.
*
* @return LinkCache
+ * @deprecated since 1.28, use MediaWikiServices instead
*/
public static function singleton() {
- if ( !self::$instance ) {
- self::$instance = new LinkCache(
- MediaWikiServices::getInstance()->getTitleFormatter()
- );
- }
-
- return self::$instance;
- }
-
- /**
- * Destroy the singleton instance
- *
- * A new one will be created next time singleton() is called.
- *
- * @since 1.22
- */
- public static function destroySingleton() {
- self::$instance = null;
- }
-
- /**
- * Set the singleton instance to a given object.
- *
- * Since we do not have an interface for LinkCache, you have to be sure the
- * given object implements all the LinkCache public methods.
- *
- * @param LinkCache $instance
- * @since 1.22
- */
- public static function setSingleton( LinkCache $instance ) {
- self::$instance = $instance;
+ return MediaWikiServices::getInstance()->getLinkCache();
}
/**
'DBLoadBalancer' => [ 'DBLoadBalancer', 'LoadBalancer' ],
'WatchedItemStore' => [ 'WatchedItemStore', WatchedItemStore::class ],
'GenderCache' => [ 'GenderCache', GenderCache::class ],
+ 'LinkCache' => [ 'LinkCache', LinkCache::class ],
'_MediaWikiTitleCodec' => [ '_MediaWikiTitleCodec', MediaWikiTitleCodec::class ],
'TitleFormatter' => [ 'TitleFormatter', TitleFormatter::class ],
'TitleParser' => [ 'TitleParser', TitleParser::class ],
<?php
+use MediaWiki\MediaWikiServices;
/**
* @group ContentHandler
MWNamespace::getCanonicalNamespaces( true );
$wgContLang->resetNamespaces();
// And LinkCache
- LinkCache::destroySingleton();
+ MediaWikiServices::getInstance()->resetServiceForTesting( 'LinkCache' );
}
protected function tearDown() {
MWNamespace::getCanonicalNamespaces( true );
$wgContLang->resetNamespaces();
// And LinkCache
- LinkCache::destroySingleton();
+ MediaWikiServices::getInstance()->resetServiceForTesting( 'LinkCache' );
parent::tearDown();
}