Page MenuHomePhabricator

Inject services when creating LanguageConverter instance in LanguageConverterFactory
Open, Needs TriagePublic

Description

The abstract class LanguageConverter is extended by many converters in mediawiki/core and is using currently the following services, which needs injection to avoid global state.

  • ContentLanguage
  • LanguageConverterFactory
  • LanguageFactory
  • LanguageNameUtils
  • LinkBatchFactory
  • LocalServerObjectCache
  • MessageCache
  • RevisionLookup
  • UserOptionsLookup

The services UserOptionsLookup (via UserOptionsManager), MessageCache and LanguageFactory (which is used by ContentLanguage, which is used by MessageCache and LinkBatchFactory) itself using the LanguageConverterFactory as a service, which gives a circular dependency.
If T243310 gets fixed than RevisionLookup is also using the service (via RevisionStore via RevisionStoreFactory via ContentHandlerFactory)

The global state about configs is handled in T244219

Event Timeline

This is only a problem when the services are injected by setters like done for SpecialPage class. When passing the services through all sub classes, than it could work.
Non of the sub classes provide own constructor at the moment (only CrhConverter has construct to fill cache, but that feals wrong, because that makes the instance of the object expensive when the data possible not needed).