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)//
- [ ] getKartographerEmbeddingHandler T275640
- [ ] getLanguageNameLookup
- [] getDefaultSnakFormatterBuilders //(static)//
- [ ] getContentLanguage
- [ ] getUserLanguage
- [x] getDataTypeFactory
- [x] getValueParserFactory
- [x] getDataValueFactory T275400
- [ ] getEntityContentFactory T275607
- [x] getEntityTypeDefinitions
- [ ] getEntityChangeFactory T275631
- [ ] getEntityDiffer T275624
- [ ] getEntityPatcher T275625
- [ ] getEntityStoreWatcher
- [ ] getEntityTitleLookup
- [ ] getEntityTitleTextLookup
- [ ] getEntityUrlLookup
- [ ] getEntityArticleIdLookup
- [ ] getEntityExistenceChecker
- [ ] getEntityRedirectChecker
- [ ] getEntityIdLookup
- [ ] getLocalRepoWikiPageMetaDataAccessor
- [ ] getEntityRevisionLookup
- [ ] getEntityRevisionLookupFactoryCallbacks
- [ ] newItemRedirectCreationInteractor
- [ ] newEditFilterHookRunner
- [ ] newTermSearchInteractor
- [ ] getEntityStore
- [ ] getEntityStoreFactoryCallbacks
- [ ] getPropertyDataTypeLookup
- [ ] getStringNormalizer
- [ ] getEntityLookup
- [ ] getPropertyLookup
- [ ] getItemLookup
- [ ] getSnakFactory
- [x] getEntityIdParser
- [ ] getEntityIdComposer
- [x] getStatementGuidParser T272166
- [ ] getChangeOpFactoryProvider
- [ ] getSiteLinkBadgeChangeOpSerializationValidator
- [ ] getEntityChangeOpProvider
- [ ] getChangeOpDeserializerFactory
- [ ] getLanguageFallbackChainFactory
- [ ] getLanguageFallbackLabelDescriptionLookupFactory
- [ ] getStatementGuidValidator T275399
- [x] getSettings
- [ ] newIdGenerator
- [ ] getStore
- [x] getLocalEntitySource T275527
- [ ] getSnakFormatterFactory
- [ ] getTermBuffer
- [ ] getTermLookup
- [ ] getPrefetchingTermLookup
- [ ] getItemUrlParser
- [ ] getItemVocabularyBaseUri
- [ ] getValueFormatterFactory T275642
- [ ] getValueSnakRdfBuilderFactory T275643
- [ ] getRdfVocabulary T275644
- [ ] getCanonicalDocumentUrls
- [ ] getExceptionLocalizer
- [ ] getExceptionLocalizers
- [ ] getSummaryFormatter
- [ ] getEntityPermissionChecker
- [ ] getTermValidatorFactory
- [ ] getTermsCollisionDetectorFactory
- [ ] getPropertyTermsCollisionDetector
- [ ] getItemTermsCollisionDetector
- [ ] getEntityConstraintProvider
- [ ] getValidatorErrorLocalizer
- [ ] getSiteLookup
- [ ] getMessageParameterFormatter
- [ ] getChangeNotifier
- [ ] getContentModelMappings T275529
- [ ] getEntityFactory
- [ ] getEnabledEntityTypes
- [ ] getLocalEntityTypes T275639
- [ ] getEntityContentDataCodec
- [ ] getBaseDataModelDeserializerFactory
- [ ] getInternalFormatDeserializerFactory
- [ ] getBaseDataModelSerializerFactory
- [ ] getCompactBaseDataModelSerializerFactory
- [ ] getAllTypesEntityDeserializer
- [ ] getInternalFormatEntityDeserializer
- [ ] getAllTypesEntitySerializer
- [ ] getCompactEntitySerializer
- [ ] getStorageEntitySerializer
- [ ] getInternalFormatStatementDeserializer
- [ ] getExternalFormatStatementDeserializer
- [ ] getStatementSerializer
- [x] getDataValueDeserializer T275501
- [ ] newItemHandler
- [ ] getPropertyTermStoreWriter
- [ ] getItemTermStoreWriter
- [ ] getNewTermStoreWriterFactory
- [ ] getFieldDefinitionsByType
- [ ] newPropertyHandler
- [ ] newPropertyInfoBuilder
- [ ] getLegacyFormatDetectorCallback
- [ ] getApiHelperFactory
- [ ] newEditEntityFactory
- [ ] newItemMergeInteractor
- [ ] getLocalEntityNamespaces
- [ ] getEntityNamespaceLookup
- [ ] getLocalEntityNamespaceLookup T275638
- [ ] getEntityIdHtmlLinkFormatterFactory
- [ ] getEntityViewFactory
- [ ] getEntityMetaTagsCreatorFactory
- [ ] getEntityDataFormatProvider
- [ ] getEntityDataUriManager
- [ ] getEntityParserOutputGeneratorFactory
- [ ] getEntityParserOutputGenerator
- [ ] getViewFactory
- [ ] getDataTypeValidatorFactory
- [x] getDataTypeDefinitions
- [ ] getWikibaseContentLanguages
- [ ] getMonolingualTextLanguages
- [ ] getTermsLanguages
- [ ] getCachingCommonsMediaFileNameLookup
- [ ] getEntityTypesConfigValue
- [ ] getSettingsValueProvider
- [ ] getUnitConverter
- [ ] getUnitStorage
- [ ] getEntityRdfBuilderFactory
- [ ] getEntityDiffVisualizerFactory
- [ ] getEntityTypeToRepositoryMapping
- [ ] getConceptBaseUris
- [x] getPropertyValueExpertsModule
- [ ] getWikibaseServices
- [ ] newEntitySourceWikibaseServices
- [ ] getDataAccessSettings
- [x] getEntitySourceDefinitions
- [ ] getEntitySearchHelperCallbacks
- [ ] getEntityLinkFormatterFactory
- [ ] getFulltextSearchTypes
- [ ] getTermFallbackCache
- [ ] getTermFallbackCacheFactory T275626
- [ ] getLogger T275623
- [ ] newFederatedPropertiesServiceFactory
- [ ] getLinkTargetEntityIdLookup
- **client/includes/WikibaseClient.php**
- [] getDefaultValueFormatterBuilders //(static)//
- [] getDefaultSnakFormatterBuilders //(static)//
- [ ] getDataTypeFactory
- [ ] getEntityIdParser
- [ ] getEntityIdComposer
- [ ] getWikibaseServices
- [ ] getDataAccessSettings
- [ ] getEntityLookup
- [] getDefaultDataTypes //(static)//
- [] getDefaultEntityTypes //(static)//
- [ ] getTermBuffer
- [ ] getTermLookup
- [ ] getPrefetchingTermLookup
- [ ] newTermSearchInteractor
- [ ] getPropertyDataTypeLookup
- [ ] getStringNormalizer
- [ ] newRepoLinker
- [ ] getLanguageFallbackChainFactory
- [ ] getLanguageFallbackLabelDescriptionLookupFactory
- [ ] getStore
- [ ] getContentLanguage
- [ ] getUserLanguage
- [x] getSettings T275412
- [] getEntitySourceDefinitionsFromSettings //(static)//
- [ ] getLogger T275515
- [ ] getSite
- [ ] getLangLinkSiteGroup
- [ ] getSiteGroup
- [ ] getSnakFormatterFactory
- [ ] getValueFormatterFactory
- [ ] getRepoItemUriParser
- [ ] getNamespaceChecker
- [ ] getLangLinkHandlerFactory
- [ ] getParserOutputDataUpdater
- [ ] getSidebarLinkBadgeDisplay
- [ ] getLanguageLinkBadgeDisplay
- [ ] getBaseDataModelDeserializerFactory
- [ ] getInternalFormatDeserializerFactory
- [ ] getAllTypesEntityDeserializer
- [ ] getInternalFormatStatementDeserializer
- [ ] getEntityDeserializerFactoryCallbacks
- [ ] getLuaEntityModules
- [ ] getCompactBaseDataModelSerializerFactory
- [ ] getCompactEntitySerializer
- [ ] getDataValueDeserializer
- [ ] getOtherProjectsSidebarGeneratorFactory
- [ ] getEntityChangeFactory
- [ ] getEntityDiffer
- [ ] getStatementGroupRendererFactory
- [ ] getDataAccessSnakFormatterFactory
- [ ] getPropertyParserFunctionRunner
- [ ] getOtherProjectsSitesProvider
- [ ] getAffectedPagesFinder
- [ ] getChangeHandler
- [ ] getRecentChangeFactory
- [ ] getDatabaseDomainNameOfLocalRepo
- [ ] getEntitySourceOfLocalRepo
- [ ] getWikibaseContentLanguages
- [ ] getTermsLanguages
- [ ] getRestrictedEntityLookup
- [ ] getPropertyOrderProvider T275518
- [ ] getEntityNamespaceLookup
- [ ] getDataAccessLanguageFallbackChain
- [ ] getTermFallbackCache
- [ ] getTermFallbackCacheFactory T275517
- [ ] getEntityIdLookup
- [ ] getDescriptionLookup
- [ ] getPropertyLabelResolver
- [ ] getReferenceFormatterFactory
- [ ] getCachedDatabasePropertyLabelResolver
- [ ] getLoadBalancerForConfiguredPropertySource
- [ ] getDatabaseDomainForPropertySource
- [ ] getWANObjectCache
- [ ] getItemSource
- [ ] getPropertySource
- [x] getDataTypeDefinitions T275383
- [x] getEntityTypeDefinitions T275383