Page MenuHomePhabricator

Implement services through MediaWikiServices
Closed, ResolvedPublic

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

Related Objects

Event Timeline

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

I think this is actually completely done now 🎉🎊