Page MenuHomePhabricator

Implement services through MediaWikiServices
Open, Needs TriagePublic

Description

Along the lines of ADR#15 and T265984, convert the services described in the current "top level factories" WikibaseRepo and WikibaseClient into 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 (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())
  • 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) T279529
  • getDefaultValueFormatterBuilders (static) T280348
  • getKartographerEmbeddingHandler T275640
  • getLanguageNameLookup T279650
  • getDefaultSnakFormatterBuilders (static) T280502
  • getContentLanguage T276581#6984372
  • getUserLanguage T278819
  • getDataTypeFactory
  • getValueParserFactory
  • getDataValueFactory T275400
  • getEntityContentFactory T276064/T275607
  • getEntityTypeDefinitions
  • getEntityChangeFactory T275631
  • getEntityDiffer T275624
  • getEntityPatcher T275625
  • getEntityStoreWatcher T278830
  • getEntityTitleLookup T276318
  • getEntityTitleTextLookup T276578
  • getEntityUrlLookup T276579
  • getEntityArticleIdLookup T276575
  • getEntityExistenceChecker T276576
  • getEntityRedirectChecker T276577
  • getEntityIdLookup T276065
  • getLocalRepoWikiPageMetaDataAccessor T277489
  • getEntityRevisionLookup T278925
  • getEntityRevisionLookupFactoryCallbacks
  • newItemRedirectCreationInteractor
  • newEditFilterHookRunner T280346
  • newTermSearchInteractor T280504
  • getEntityStore T278828
  • getEntityStoreFactoryCallbacks
  • getPropertyDataTypeLookup T279526
  • getStringNormalizer T276430
  • getEntityLookup T278926
  • getPropertyLookup T279528
  • getItemLookup T279527
  • getSnakFactory T279937
  • getEntityIdParser
  • getEntityIdComposer T276062
  • getStatementGuidParser T272166
  • getChangeOpFactoryProvider T279936
  • getSiteLinkBadgeChangeOpSerializationValidator T276580
  • getEntityChangeOpProvider T276245
  • getChangeOpDeserializerFactory T280120
  • getLanguageFallbackChainFactory T276457
  • getLanguageFallbackLabelDescriptionLookupFactory T278692
  • getStatementGuidValidator T275399
  • getSettings
  • newIdGenerator T276066
  • getStore T277490
  • getLocalEntitySource T275527
  • getSnakFormatterFactory T279938
  • getTermBuffer T277774
  • getTermLookup T277773
  • getPrefetchingTermLookup T277314
  • getItemUrlParser T278821
  • getItemVocabularyBaseUri T277576
  • getValueFormatterFactory T275642
  • getValueSnakRdfBuilderFactory T275643
  • getRdfVocabulary T275644
  • getCanonicalDocumentUrls T275644
  • getExceptionLocalizer T279513
  • getExceptionLocalizers [Part of T279513]
  • getSummaryFormatter T276581/T279940
  • getEntityPermissionChecker T277487
  • getTermValidatorFactory T278695
  • getTermsCollisionDetectorFactory T276312
  • getPropertyTermsCollisionDetector T276313
  • getItemTermsCollisionDetector T276314
  • getEntityConstraintProvider T278829
  • getValidatorErrorLocalizer T279516
  • getSiteLookup T279681
  • getMessageParameterFormatter T277577
  • getChangeNotifier T278826
  • getContentModelMappings T275529
  • getEntityFactory T277578
  • getEnabledEntityTypes T280142
  • getLocalEntityTypes T275639
  • getEntityContentDataCodec T279659
  • getBaseDataModelDeserializerFactory T277052
  • getInternalFormatDeserializerFactory T277299
  • getBaseDataModelSerializerFactory T276533
  • getCompactBaseDataModelSerializerFactory T276534
  • getAllTypesEntityDeserializer T277194
  • getInternalFormatEntityDeserializer T277532
  • getAllTypesEntitySerializer T276536
  • getCompactEntitySerializer T276538
  • getStorageEntitySerializer T276541
  • getInternalFormatStatementDeserializer T277533
  • getExternalFormatStatementDeserializer T277195
  • getStatementSerializer T276570
  • getDataValueDeserializer T275501
  • newItemHandler T279939
  • getPropertyTermStoreWriter T277026
  • getItemTermStoreWriter T277025
  • getNewTermStoreWriterFactory T276456
  • getFieldDefinitionsByType T280002
  • newPropertyHandler T280143
  • newPropertyInfoBuilder T279660
  • getLegacyFormatDetectorCallback T279769
  • getApiHelperFactory
  • newEditEntityFactory T280140
  • newItemMergeInteractor
  • getLocalEntityNamespaces T280144
  • getEntityNamespaceLookup T277313
  • getLocalEntityNamespaceLookup T275638
  • getEntityIdHtmlLinkFormatterFactory T279673
  • getEntityViewFactory T279790
  • getEntityMetaTagsCreatorFactory T279791
  • getEntityDataFormatProvider T279792
  • getEntityDataUriManager T279913
  • getEntityParserOutputGeneratorFactory T280145
  • getEntityParserOutputGenerator T280145
  • getViewFactory T280123
  • getDataTypeValidatorFactory T277664
  • getDataTypeDefinitions T265984
  • getWikibaseContentLanguages T276546
  • getMonolingualTextLanguages T276912
  • getTermsLanguages T276913
  • getCachingCommonsMediaFileNameLookup T279918
  • getEntityTypesConfigValue T280685
  • getSettingsValueProvider T280686
  • getUnitConverter T276547
  • getUnitStorage T276547
  • getEntityRdfBuilderFactory T276548
  • getEntityDiffVisualizerFactory T280122
  • getEntityTypeToRepositoryMapping T280499
  • getConceptBaseUris T279793
  • getPropertyValueExpertsModule
  • getWikibaseServices T276931
  • getDataAccessSettings T276549
  • getEntitySourceDefinitions
  • getEntitySearchHelperCallbacks T280687
  • getEntityLinkFormatterFactory T280501
  • getFulltextSearchTypes T279919
  • getTermFallbackCache T275883
  • getTermFallbackCacheFactory T275626
  • getLogger T275623
  • newFederatedPropertiesServiceFactory T279663
  • getLinkTargetEntityIdLookup T277488

Related Objects

Event Timeline

There are a very large number of changes, so older changes are hidden. Show Older Changes

Notes from story time: we didn’t estimate or pick this up yet, but once we do, we assume that it won’t make sense to break this down into a hundred subtasks from the start – after possibly breaking it down into Repo and Client subtasks, we should leave these in the “parent tasks” column, and decide on the next few services to migrate during the task inspection/breakdown meeting (based on which services have dependencies on other unmigrated services), and create tasks for those services “on demand”.

If anyone wants to get started with this, a good next service to convert in WikibaseRepo might be the StatementGuidParser: it’s a simple service, but injected into a number of API modules. (Also, we currently create several instances of it per edit request.)

I’ll pick this one up so we have one (hopefully) clean example of a migrated service.