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**
- [x] getDefaultValidatorBuilders //(static)// T279529
- [x] getDefaultValueFormatterBuilders //(static)// T280348
- [x] getKartographerEmbeddingHandler T275640
- [x] getLanguageNameLookup T279650
- [x] getDefaultSnakFormatterBuilders //(static)// T280502
- [x] getContentLanguage T276581#6984372
- [x] getUserLanguage T278819
- [x] getDataTypeFactory
- [x] getValueParserFactory
- [x] getDataValueFactory T275400
- [x] getEntityContentFactory T276064/T275607
- [x] getEntityTypeDefinitions
- [x] getEntityChangeFactory T275631
- [x] getEntityDiffer T275624
- [x] getEntityPatcher T275625
- [x] getEntityStoreWatcher T278830
- [x] getEntityTitleLookup T276318
- [x] getEntityTitleTextLookup T276578
- [x] getEntityUrlLookup T276579
- [x] getEntityArticleIdLookup T276575
- [x] getEntityExistenceChecker T276576
- [x] getEntityRedirectChecker T276577
- [x] getEntityIdLookup T276065
- [x] getLocalRepoWikiPageMetaDataAccessor T277489
- [x] getEntityRevisionLookup T278925
- [ ] getEntityRevisionLookupFactoryCallbacks
- [ ] newItemRedirectCreationInteractor
- [x] newEditFilterHookRunner T280346
- [ ] newTermSearchInteractor T280504
- [x] getEntityStore T278828
- [ ] getEntityStoreFactoryCallbacks
- [x] getPropertyDataTypeLookup T279526
- [x] getStringNormalizer T276430
- [x] getEntityLookup T278926
- [x] getPropertyLookup T279528
- [x] getItemLookup T279527
- [x] getSnakFactory T279937
- [x] getEntityIdParser
- [x] getEntityIdComposer T276062
- [x] getStatementGuidParser T272166
- [x] getChangeOpFactoryProvider T279936
- [x] getSiteLinkBadgeChangeOpSerializationValidator T276580
- [x] getEntityChangeOpProvider T276245
- [x] getChangeOpDeserializerFactory T280120
- [x] getLanguageFallbackChainFactory T276457
- [x] getLanguageFallbackLabelDescriptionLookupFactory T278692
- [x] getStatementGuidValidator T275399
- [x] getSettings
- [x] newIdGenerator T276066
- [x] getStore T277490
- [x] getLocalEntitySource T275527
- [x] getSnakFormatterFactory T279938
- [x] getTermBuffer T277774
- [x] getTermLookup T277773
- [x] getPrefetchingTermLookup T277314
- [x] getItemUrlParser T278821
- [x] getItemVocabularyBaseUri T277576
- [x] getValueFormatterFactory T275642
- [x] getValueSnakRdfBuilderFactory T275643
- [x] getRdfVocabulary T275644
- [x] getCanonicalDocumentUrls T275644
- [x] getExceptionLocalizer T279513
- [x] getExceptionLocalizers [Part of T279513]
- [x] getSummaryFormatter T276581/T279940
- [x] getEntityPermissionChecker T277487
- [x] getTermValidatorFactory T278695
- [x] getTermsCollisionDetectorFactory T276312
- [x] getPropertyTermsCollisionDetector T276313
- [x] getItemTermsCollisionDetector T276314
- [x] getEntityConstraintProvider T278829
- [x] getValidatorErrorLocalizer T279516
- [x] getSiteLookup T279681
- [x] getMessageParameterFormatter T277577
- [x] getChangeNotifier T278826
- [x] getContentModelMappings T275529
- [x] getEntityFactory T277578
- [x] getEnabledEntityTypes T280142
- [x] getLocalEntityTypes T275639
- [x] getEntityContentDataCodec T279659
- [x] getBaseDataModelDeserializerFactory T277052
- [x] getInternalFormatDeserializerFactory T277299
- [x] getBaseDataModelSerializerFactory T276533
- [x] getCompactBaseDataModelSerializerFactory T276534
- [x] getAllTypesEntityDeserializer T277194
- [x] getInternalFormatEntityDeserializer T277532
- [x] getAllTypesEntitySerializer T276536
- [x] getCompactEntitySerializer T276538
- [x] getStorageEntitySerializer T276541
- [x] getInternalFormatStatementDeserializer T277533
- [x] getExternalFormatStatementDeserializer T277195
- [x] getStatementSerializer T276570
- [x] getDataValueDeserializer T275501
- [x] newItemHandler T279939
- [x] getPropertyTermStoreWriter T277026
- [x] getItemTermStoreWriter T277025
- [x] getNewTermStoreWriterFactory T276456
- [x] getFieldDefinitionsByType T280002
- [x] newPropertyHandler T280143
- [x] newPropertyInfoBuilder T279660
- [x] getLegacyFormatDetectorCallback T279769
- [ ] getApiHelperFactory
- [x] newEditEntityFactory T280140
- [ ] newItemMergeInteractor
- [x] getLocalEntityNamespaces T280144
- [x] getEntityNamespaceLookup T277313
- [x] getLocalEntityNamespaceLookup T275638
- [x] getEntityIdHtmlLinkFormatterFactory T279673
- [x] getEntityViewFactory T279790
- [x] getEntityMetaTagsCreatorFactory T279791
- [x] getEntityDataFormatProvider T279792
- [x] getEntityDataUriManager T279913
- [x] getEntityParserOutputGeneratorFactory T280145
- [x] getEntityParserOutputGenerator T280145
- [x] getViewFactory T280123
- [x] getDataTypeValidatorFactory T277664
- [x] getDataTypeDefinitions T265984
- [x] getWikibaseContentLanguages T276546
- [x] getMonolingualTextLanguages T276912
- [x] getTermsLanguages T276913
- [x] getCachingCommonsMediaFileNameLookup T279918
- [x] getEntityTypesConfigValue T280685
- [x] getSettingsValueProvider T280686
- [x] getUnitConverter T276547
- [x] getUnitStorage T276547
- [x] getEntityRdfBuilderFactory T276548
- [ ] getEntityDiffVisualizerFactory T280122
- [x] getEntityTypeToRepositoryMapping T280499
- [x] getConceptBaseUris T279793
- [x] getPropertyValueExpertsModule
- [x] getWikibaseServices T276931
- [x] getDataAccessSettings T276549
- [x] getEntitySourceDefinitions
- [x] getEntitySearchHelperCallbacks T280687
- [ ] getEntityLinkFormatterFactory T280501
- [x] getFulltextSearchTypes T279919
- [x] getTermFallbackCache T275883
- [x] getTermFallbackCacheFactory T275626
- [x] getLogger T275623
- [x] newFederatedPropertiesServiceFactory T279663
- [x] getLinkTargetEntityIdLookup T277488
- **client/includes/WikibaseClient.php**
- [x] getDefaultValueFormatterBuilders //(static)// T280333
- [x] getDefaultSnakFormatterBuilders //(static)// T280345
- [x] getDataTypeFactory T276552
- [x] getEntityIdParser T275886
- [x] getEntityIdComposer T275887
- [x] getWikibaseServices T276952
- [x] getDataAccessSettings T276553
- [x] getEntityLookup T278992
- [x] getDefaultDataTypes //(static)// T275383
- [x] getDefaultEntityTypes //(static)// T275383
- [x] getTermBuffer T277897
- [x] getTermLookup T277898
- [x] getPrefetchingTermLookup T277304
- [x] newTermSearchInteractor T279511
- [x] getPropertyDataTypeLookup T279920
- [x] getStringNormalizer T276431
- [x] newRepoLinker T276331
- [x] getLanguageFallbackChainFactory T276458
- [x] getLanguageFallbackLabelDescriptionLookupFactory T279084
- [x] getStore T277482
- [x] getContentLanguage T280571
- [x] getUserLanguage T279802
- [x] getSettings T275412
- [x] getEntitySourceDefinitionsFromSettings //(static)// T275412
- [x] getLogger T275515
- [x] getSite T276349
- [x] getLangLinkSiteGroup T277569
- [x] getSiteGroup T277568
- [x] getSnakFormatterFactory T279924
- [x] getValueFormatterFactory T276529
- [x] getRepoItemUriParser T278742
- [x] getNamespaceChecker T276554
- [x] getLangLinkHandlerFactory T280374
- [x] getParserOutputDataUpdater T280511
- [x] getSidebarLinkBadgeDisplay T279510
- [x] getLanguageLinkBadgeDisplay T280335
- [x] getBaseDataModelDeserializerFactory T276427
- [x] getInternalFormatDeserializerFactory T277532
- [x] getAllTypesEntityDeserializer T277570
- [x] getInternalFormatStatementDeserializer T277570
- [x] getEntityDeserializerFactoryCallbacks T277570
- [x] getLuaEntityModules T280337
- [x] getCompactBaseDataModelSerializerFactory T276535
- [x] getCompactEntitySerializer T276539
- [x] getDataValueDeserializer T276109
- [x] getOtherProjectsSidebarGeneratorFactory T280338
- [x] getEntityChangeFactory T276951
- [x] getEntityDiffer T276555
- [x] getStatementGroupRendererFactory T280572
- [x] getDataAccessSnakFormatterFactory T279995
- [x] getPropertyParserFunctionRunner T280653
- [x] getOtherProjectsSitesProvider T276556
- [x] getAffectedPagesFinder T278991
- [x] getChangeHandler T279512
- [x] getRecentChangeFactory T277571
- [x] getDatabaseDomainNameOfLocalRepo T277481
- [x] getEntitySourceOfLocalRepo T277481
- [x] getWikibaseContentLanguages T277567
- [x] getTermsLanguages T279514
- [x] getRestrictedEntityLookup T279921
- [x] getPropertyOrderProvider T275518
- [x] getEntityNamespaceLookup T277303
- [x] getDataAccessLanguageFallbackChain T277572
- [x] getTermFallbackCache T275884
- [x] getTermFallbackCacheFactory T275517
- [x] getEntityIdLookup T276110
- [x] getDescriptionLookup T279075
- [x] getPropertyLabelResolver T277575
- [x] getReferenceFormatterFactory T280573
- [x] getCachedDatabasePropertyLabelResolver [Removed T277575]
- [x] getLoadBalancerForConfiguredPropertySource [Removed T277575]
- [x] getDatabaseDomainForPropertySource [Removed T277575]
- [x] getWANObjectCache [Removed T277575]
- [x] getItemSource T277573
- [x] getPropertySource T277574
- [x] getDataTypeDefinitions T275383
- [x] getEntityTypeDefinitions T275383