Along the lines of [[ https://doc.wikimedia.org/Wikibase/master/php/adr_0015.html | ADR#15 ]] and T265984, convert the services described in the current "top level factories" `WikibaseRepo` and `WikibaseClient` into [[ https://www.mediawiki.org/wiki/Dependency_Injection#Service_Wiring | service wiring ]].
As a result, a lot of boilerplate code can be avoided and - through `extension.json` - dependencies can be cleanly injected into MediaWiki pages ([[ https://gerrit.wikimedia.org/r/c/mediawiki/extensions/Wikibase/+/642040/5/extension-repo.json#17 | e.g. ]]) without reaching into global scope.
**A/C:**
[ ] `WikibaseRepo` and `WikibaseClient` no longer have instances (`getDefaultInstance()` gone, constructor empty+private), all service getters are static wrappers around a `ContainerInterface` (like current [WikibaseRepo::getEntityIdParser()](https://gerrit.wikimedia.org/g/mediawiki/extensions/Wikibase/+/4c3643343656cb2c30374e059de74dcbf6a49884/repo/includes/WikibaseRepo.php#939))
[] Test infrastructure that was custom built to reset changes to these services between tests is removed
[] i.e. remove WikibaseRepo::resetClassStatics() and WikibaseClient::getDefaultInstance( 'reset' )
**Process to choose services to migrate**
Start with the more core services to try and eliminate the dependency issues:
Bootstrapping WikibaseClient: start with the newInstance() dependencies – DataTypeDefinitions, EntityTypeDefinitions, EntitySourceDenifitions – then continue with more services.
Engineer picks up a service and:
- Creates a ticket, does the migration and commits all the changes to the ticket
Once done with the migration of one service, the next service to migrate will be given by the migration that we have just migrated e.g. the one that depends on the one we just migrated and makes tickets for all the next available services to migrate. In absence of this go to any other service in the other repository.
**Process to migrate one service (example: T272166)**
- Move the service initialization code to the service wiring file (repo/WikibaseRepo.ServiceWiring.php or client/WikibaseClient.ServiceWiring.php)
- Make the WikibaseRepo/WikibaseClient method static and load the service from the container
- Update callers of the WikibaseRepo/WikibaseClient method to either call the method statically or to properly inject the service where possible
- Including callers in other extensions: use code search
- Add unit test for service wiring
**This is the list of services that will be migrated:**
- ** repo/includes/WikibaseRepo.php**
- [] getDefaultValidatorBuilders //(static)//
- [] getDefaultValueFormatterBuilders //(static)//
- [x] getKartographerEmbeddingHandler T275640
- [ ] getLanguageNameLookup
- [] getDefaultSnakFormatterBuilders //(static)//
- [ ] getContentLanguage
- [ ] getUserLanguage
- [x] getDataTypeFactory
- [x] getValueParserFactory
- [x] getDataValueFactory T275400
- [x] getEntityContentFactory T276064/T275607
- [x] getEntityTypeDefinitions
- [x] getEntityChangeFactory T275631
- [x] getEntityDiffer T275624
- [x] getEntityPatcher T275625
- [ ] getEntityStoreWatcher
- [x] getEntityTitleLookup T276318
- [x] getEntityTitleTextLookup T276578
- [x] getEntityUrlLookup T276579
- [x] getEntityArticleIdLookup T276575
- [x] getEntityExistenceChecker T276576
- [x] getEntityRedirectChecker T276577
- [x] getEntityIdLookup T276065
- [ ] getLocalRepoWikiPageMetaDataAccessor T277489
- [ ] getEntityRevisionLookup
- [ ] getEntityRevisionLookupFactoryCallbacks
- [ ] newItemRedirectCreationInteractor
- [ ] newEditFilterHookRunner
- [ ] newTermSearchInteractor
- [ ] getEntityStore
- [ ] getEntityStoreFactoryCallbacks
- [ ] getPropertyDataTypeLookup
- [x] getStringNormalizer T276430
- [ ] getEntityLookup
- [ ] getPropertyLookup
- [ ] getItemLookup
- [ ] getSnakFactory
- [ ] getEntityIdParser
- [x] getEntityIdComposer T276062
- [x] getStatementGuidParser T272166
- [ ] getChangeOpFactoryProvider
- [x] getSiteLinkBadgeChangeOpSerializationValidator T276580
- [x] getEntityChangeOpProvider T276245
- [ ] getChangeOpDeserializerFactory
- [x] getLanguageFallbackChainFactory T276457
- [ ] getLanguageFallbackLabelDescriptionLookupFactory
- [x] getStatementGuidValidator T275399
- [x] getSettings
- [x] newIdGenerator T276066
- [ ] getStore T277490
- [x] getLocalEntitySource T275527
- [ ] getSnakFormatterFactory
- [ ] getTermBuffer T277664
- [ ] getTermLookup T277773
- [ ] getPrefetchingTermLookup T277314
- [ ] getItemUrlParser
- [ ] getItemVocabularyBaseUri
- [x] getValueFormatterFactory T275642
- [x] getValueSnakRdfBuilderFactory T275643
- [x] getRdfVocabulary T275644
- [ ] getCanonicalDocumentUrls
- [ ] getExceptionLocalizer
- [ ] getExceptionLocalizers
- [ ] getSummaryFormatter T276581
- [ ] getEntityPermissionChecker T277487
- [ ] getTermValidatorFactory
- [x] getTermsCollisionDetectorFactory T276312
- [x] getPropertyTermsCollisionDetector T276313
- [x] getItemTermsCollisionDetector T276314
- [ ] getEntityConstraintProvider
- [ ] getValidatorErrorLocalizer
- [ ] getSiteLookup
- [ ] getMessageParameterFormatter
- [ ] getChangeNotifier
- [x] getContentModelMappings T275529
- [ ] getEntityFactory T277578
- [ ] getEnabledEntityTypes
- [x] getLocalEntityTypes T275639
- [ ] getEntityContentDataCodec
- [x] getBaseDataModelDeserializerFactory T277052
- [ ] getInternalFormatDeserializerFactory T277299
- [x] getBaseDataModelSerializerFactory T276533
- [x] getCompactBaseDataModelSerializerFactory T276534
- [x] getAllTypesEntityDeserializer T277194
- [ ] getInternalFormatEntityDeserializer T277532
- [x] getAllTypesEntitySerializer T276536
- [x] getCompactEntitySerializer T276538
- [x] getStorageEntitySerializer T276541
- [ ] getInternalFormatStatementDeserializer T277533
- [x] getExternalFormatStatementDeserializer T277195
- [x] getStatementSerializer T276570
- [x] getDataValueDeserializer T275501
- [ ] newItemHandler
- [x] getPropertyTermStoreWriter T277026
- [x] getItemTermStoreWriter T277025
- [x] getNewTermStoreWriterFactory T276456
- [ ] getFieldDefinitionsByType
- [ ] newPropertyHandler
- [ ] newPropertyInfoBuilder
- [ ] getLegacyFormatDetectorCallback
- [ ] getApiHelperFactory
- [ ] newEditEntityFactory
- [ ] newItemMergeInteractor
- [ ] getLocalEntityNamespaces
- [x] getEntityNamespaceLookup T277313
- [x] getLocalEntityNamespaceLookup T275638
- [ ] getEntityIdHtmlLinkFormatterFactory
- [ ] getEntityViewFactory
- [ ] getEntityMetaTagsCreatorFactory
- [ ] getEntityDataFormatProvider
- [ ] getEntityDataUriManager
- [ ] getEntityParserOutputGeneratorFactory
- [ ] getEntityParserOutputGenerator
- [ ] getViewFactory
- [ ] getDataTypeValidatorFactory T277664
- [ ] getDataTypeDefinitions
- [x] getWikibaseContentLanguages T276546
- [x] getMonolingualTextLanguages T276912
- [x] getTermsLanguages T276913
- [ ] getCachingCommonsMediaFileNameLookup
- [ ] getEntityTypesConfigValue
- [ ] getSettingsValueProvider
- [x] getUnitConverter T276547
- [x] getUnitStorage T276547
- [x] getEntityRdfBuilderFactory T276548
- [ ] getEntityDiffVisualizerFactory
- [ ] getEntityTypeToRepositoryMapping
- [ ] getConceptBaseUris
- [x] getPropertyValueExpertsModule
- [x] getWikibaseServices T276931
- [x] getDataAccessSettings T276549
- [x] getEntitySourceDefinitions
- [ ] getEntitySearchHelperCallbacks
- [ ] getEntityLinkFormatterFactory
- [ ] getFulltextSearchTypes
- [x] getTermFallbackCache T275883
- [x] getTermFallbackCacheFactory T275626
- [x] getLogger T275623
- [ ] newFederatedPropertiesServiceFactory
- [ ] getLinkTargetEntityIdLookup T277488
- **client/includes/WikibaseClient.php**
- [] getDefaultValueFormatterBuilders //(static)//
- [] getDefaultSnakFormatterBuilders //(static)//
- [x] getDataTypeFactory T276552
- [x] getEntityIdParser T275886
- [x] getEntityIdComposer T275887
- [x] getWikibaseServices T276952
- [x] getDataAccessSettings T276553
- [ ] getEntityLookup
- [] getDefaultDataTypes //(static)//
- [] getDefaultEntityTypes //(static)//
- [ ] getTermBuffer
- [ ] getTermLookup
- [ ] getPrefetchingTermLookup T277304
- [ ] newTermSearchInteractor
- [ ] getPropertyDataTypeLookup
- [x] getStringNormalizer T276431
- [x] newRepoLinker T276331
- [x] getLanguageFallbackChainFactory T276458
- [ ] getLanguageFallbackLabelDescriptionLookupFactory
- [ ] getStore T277482
- [ ] getContentLanguage
- [ ] getUserLanguage
- [x] getSettings T275412
- [] getEntitySourceDefinitionsFromSettings //(static)//
- [x] getLogger T275515
- [x] getSite T276349
- [ ] getLangLinkSiteGroup
- [ ] getSiteGroup
- [ ] getSnakFormatterFactory
- [x] getValueFormatterFactory T276529
- [ ] getRepoItemUriParser
- [x] getNamespaceChecker T276554
- [ ] getLangLinkHandlerFactory
- [ ] getParserOutputDataUpdater
- [ ] getSidebarLinkBadgeDisplay
- [ ] getLanguageLinkBadgeDisplay
- [x] getBaseDataModelDeserializerFactory T276427
- [x] getInternalFormatDeserializerFactory
- [ ] getAllTypesEntityDeserializer
- [ ] getInternalFormatStatementDeserializer
- [ ] getEntityDeserializerFactoryCallbacks
- [ ] getLuaEntityModules
- [x] getCompactBaseDataModelSerializerFactory T276535
- [x] getCompactEntitySerializer T276539
- [x] getDataValueDeserializer T276109
- [ ] getOtherProjectsSidebarGeneratorFactory
- [x] getEntityChangeFactory T276951
- [x] getEntityDiffer T276555
- [ ] getStatementGroupRendererFactory
- [ ] getDataAccessSnakFormatterFactory
- [ ] getPropertyParserFunctionRunner
- [x] getOtherProjectsSitesProvider T276556
- [ ] getAffectedPagesFinder
- [ ] getChangeHandler
- [ ] getRecentChangeFactory
- [ ] getDatabaseDomainNameOfLocalRepo
- [ ] getEntitySourceOfLocalRepo T277481
- [ ] getWikibaseContentLanguages
- [ ] getTermsLanguages
- [ ] getRestrictedEntityLookup
- [x] getPropertyOrderProvider T275518
- [x] getEntityNamespaceLookup T277303
- [ ] getDataAccessLanguageFallbackChain
- [x] getTermFallbackCache T275884
- [x] getTermFallbackCacheFactory T275517
- [x] getEntityIdLookup T276110
- [ ] getDescriptionLookup
- [ ] getPropertyLabelResolver
- [ ] getReferenceFormatterFactory
- [ ] getCachedDatabasePropertyLabelResolver
- [ ] getLoadBalancerForConfiguredPropertySource
- [ ] getDatabaseDomainForPropertySource
- [ ] getWANObjectCache
- [ ] getItemSource
- [ ] getPropertySource
- [x] getDataTypeDefinitions T275383
- [x] getEntityTypeDefinitions T275383