Page MenuHomePhabricator

OutputFormatValueFormatterFactory should create DataValue formatters on demand instead of creating them all upfront
Closed, ResolvedPublic

Description

Problem: Currently, all DataValue formatter callbacks are called when creating a new DispatchingValueFormatter through the OutputFormatValueFormatterFactory. This happens for example in the WikibaseRepo.MessageParameterFormatter service. However, that means that the format-factory-callback for a wikibase-sense is executed when just trying to create a new bare Item. This can lead to unintuitive errors, as it happened in Add lexeme language to formatted sense ID (Ieaf6fabd).

One option to tackle this would be to make DispatchingValueFormatter create the formatters on demand as needed and then cache them. That way we should have less coupling in practice.

Details

Event Timeline

Change 875295 had a related patch set uploaded (by Lucas Werkmeister (WMDE); author: Lucas Werkmeister (WMDE)):

[mediawiki/extensions/Wikibase@master] Make DispatchingValueFormatter lazy

https://gerrit.wikimedia.org/r/875295

One option to tackle this would be to make DispatchingValueFormatter create the formatters on demand as needed and then cache them.

I tried this out and it doesn’t seem to break anything in the tests \o/

Change 875295 merged by jenkins-bot:

[mediawiki/extensions/Wikibase@master] Make DispatchingValueFormatter lazy

https://gerrit.wikimedia.org/r/875295