WMDE-leszek has uploaded a new change for review. ( https://gerrit.wikimedia.org/r/373275 )
Change subject: Use LFChainFactory instance provided by WikibaseServices in Client and (optionally) Repo ...................................................................... Use LFChainFactory instance provided by WikibaseServices in Client and (optionally) Repo Change-Id: I3d07d26a21fc699db7cac9c5f034ab3eb2d4427c --- M client/includes/WikibaseClient.php M data-access/src/MultipleRepositoryAwareWikibaseServices.php M data-access/src/WikibaseServices.php M data-access/tests/phpunit/MultipleRepositoryAwareWikibaseServicesTest.php M repo/includes/WikibaseRepo.php 5 files changed, 30 insertions(+), 10 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Wikibase refs/changes/75/373275/1 diff --git a/client/includes/WikibaseClient.php b/client/includes/WikibaseClient.php index 4c8dac1..e980c2a 100644 --- a/client/includes/WikibaseClient.php +++ b/client/includes/WikibaseClient.php @@ -152,11 +152,6 @@ private $entityIdComposer = null; /** - * @var LanguageFallbackChainFactory|null - */ - private $languageFallbackChainFactory = null; - - /** * @var ClientStore|null */ private $store = null; @@ -507,11 +502,7 @@ * @return LanguageFallbackChainFactory */ public function getLanguageFallbackChainFactory() { - if ( $this->languageFallbackChainFactory === null ) { - $this->languageFallbackChainFactory = new LanguageFallbackChainFactory(); - } - - return $this->languageFallbackChainFactory; + return $this->getWikibaseServices()->getLanguageFallbackChainFactory(); } /** diff --git a/data-access/src/MultipleRepositoryAwareWikibaseServices.php b/data-access/src/MultipleRepositoryAwareWikibaseServices.php index 39ace09..006247f 100644 --- a/data-access/src/MultipleRepositoryAwareWikibaseServices.php +++ b/data-access/src/MultipleRepositoryAwareWikibaseServices.php @@ -8,6 +8,7 @@ use Wikibase\DataModel\Services\Entity\EntityPrefetcher; use Wikibase\DataModel\Services\EntityId\PrefixMappingEntityIdParserFactory; use Wikibase\DataModel\Services\Term\TermBuffer; +use Wikibase\LanguageFallbackChainFactory; use Wikibase\Lib\EntityIdComposer; use Wikibase\Lib\EntityTypeDefinitions; use Wikibase\Lib\Interactors\TermSearchInteractorFactory; @@ -131,6 +132,9 @@ 'EntityStoreWatcher' => function() use ( $multiRepositoryServices ) { return $multiRepositoryServices; }, + 'LanguageFallbackChainFactory' => function () use ( $genericServices ) { + return $genericServices->getLanguageFallbackChainFactory(); + }, 'PropertyInfoLookup' => function() use ( $multiRepositoryServices ) { return $multiRepositoryServices->getPropertyInfoLookup(); }, @@ -175,6 +179,13 @@ } /** + * @return LanguageFallbackChainFactory + */ + public function getLanguageFallbackChainFactory() { + return $this->getService( 'LanguageFallbackChainFactory' ); + } + + /** * @return PropertyInfoLookup */ public function getPropertyInfoLookup() { diff --git a/data-access/src/WikibaseServices.php b/data-access/src/WikibaseServices.php index 113e28c..3b45a49 100644 --- a/data-access/src/WikibaseServices.php +++ b/data-access/src/WikibaseServices.php @@ -4,6 +4,7 @@ use Wikibase\DataModel\Services\Entity\EntityPrefetcher; use Wikibase\DataModel\Services\Term\TermBuffer; +use Wikibase\LanguageFallbackChainFactory; use Wikibase\Lib\Interactors\TermSearchInteractorFactory; use Wikibase\Lib\Store\EntityInfoBuilderFactory; use Wikibase\Lib\Store\EntityNamespaceLookup; @@ -47,6 +48,11 @@ public function getEntityStoreWatcher(); /** + * @return LanguageFallbackChainFactory + */ + public function getLanguageFallbackChainFactory(); + + /** * Note: Instance returned is not guaranteed to be a caching decorator. * Callers should take care of caching themselves. * diff --git a/data-access/tests/phpunit/MultipleRepositoryAwareWikibaseServicesTest.php b/data-access/tests/phpunit/MultipleRepositoryAwareWikibaseServicesTest.php index 7652316..b26e3ae 100644 --- a/data-access/tests/phpunit/MultipleRepositoryAwareWikibaseServicesTest.php +++ b/data-access/tests/phpunit/MultipleRepositoryAwareWikibaseServicesTest.php @@ -7,6 +7,7 @@ use Wikibase\DataModel\Entity\BasicEntityIdParser; use Wikibase\DataModel\Services\Entity\EntityPrefetcher; use Wikibase\DataModel\Services\Term\TermBuffer; +use Wikibase\LanguageFallbackChainFactory; use Wikibase\Lib\EntityIdComposer; use Wikibase\Lib\EntityTypeDefinitions; use Wikibase\Lib\Interactors\TermSearchInteractorFactory; @@ -103,6 +104,12 @@ $this->assertInstanceOf( EntityStoreWatcher::class, $wikibaseServices->getEntityStoreWatcher() ); } + public function testGetLanguageFallbackChainFactory() { + $wikibaseServices = $this->newMultipleRepositoryAwareWikibaseServices(); + + $this->assertInstanceOf( LanguageFallbackChainFactory::class, $wikibaseServices->getLanguageFallbackChainFactory() ); + } + public function testGetPropertyInfoLookup() { $wikibaseServices = $this->newMultipleRepositoryAwareWikibaseServices(); @@ -141,6 +148,7 @@ 'EntityPrefetcher', 'EntityRevisionLookup', 'EntityStoreWatcher', + 'LanguageFallbackChainFactory', 'PropertyInfoLookup', 'StringNormalizer', 'TermBuffer', diff --git a/repo/includes/WikibaseRepo.php b/repo/includes/WikibaseRepo.php index bf86b45..45e2fe2 100644 --- a/repo/includes/WikibaseRepo.php +++ b/repo/includes/WikibaseRepo.php @@ -912,6 +912,10 @@ * @return LanguageFallbackChainFactory */ public function getLanguageFallbackChainFactory() { + if ( $this->wikibaseServices !== null ) { + return $this->wikibaseServices->getLanguageFallbackChainFactory(); + } + if ( $this->languageFallbackChainFactory === null ) { $this->languageFallbackChainFactory = new LanguageFallbackChainFactory(); } -- To view, visit https://gerrit.wikimedia.org/r/373275 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I3d07d26a21fc699db7cac9c5f034ab3eb2d4427c Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/Wikibase Gerrit-Branch: master Gerrit-Owner: WMDE-leszek <leszek.mani...@wikimedia.de> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits