Aude has uploaded a new change for review. https://gerrit.wikimedia.org/r/237433
Change subject: Overwrite some default callbacks when constructing SummaryFormatter ...................................................................... Overwrite some default callbacks when constructing SummaryFormatter We define a specialized formatter for entity ids for use in summaries, and register it for the 'VT:wikibase-entityid' key. In order for this to get used, formatters registered for individual entity types (resp data types) must be skipped or overwritten. Reported by Ivan A. Krestinin: https://www.wikidata.org/wiki/?diff=250029949&oldid=249601743 Change-Id: I8b443372c900238b1dc1c6586795a4e1833322ac (cherry picked from commit b80169e39e4822a14fe17edfd270b4c274bc9bc8) --- M repo/includes/WikibaseRepo.php 1 file changed, 11 insertions(+), 9 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Wikibase refs/changes/33/237433/1 diff --git a/repo/includes/WikibaseRepo.php b/repo/includes/WikibaseRepo.php index 9b328fb..35d401b 100644 --- a/repo/includes/WikibaseRepo.php +++ b/repo/includes/WikibaseRepo.php @@ -880,16 +880,18 @@ // Create a new ValueFormatterFactory, and override the formatter for entity IDs. $valueFormatterFactory = $this->newValueFormatterFactory(); - $valueFormatterFactory->setFormatterFactoryCallback( - 'VT:wikibase-entityid', - function ( $format, FormatterOptions $options ) use ( $idFormatter ) { - if ( $format === SnakFormatter::FORMAT_PLAIN ) { - return new EntityIdValueFormatter( $idFormatter ); - } else { - return null; + foreach ( $this->getEntityFactory()->getEntityTypes() as $entityType ) { + $valueFormatterFactory->setFormatterFactoryCallback( + "PT:wikibase-$entityType", + function ( $format, FormatterOptions $options ) use ( $idFormatter ) { + if ( $format === SnakFormatter::FORMAT_PLAIN ) { + return new EntityIdValueFormatter( $idFormatter ); + } else { + return null; + } } - } - ); + ); + } // Create a new SnakFormatterFactory based on the specialized ValueFormatterFactory. $snakFormatterFactory = new OutputFormatSnakFormatterFactory( -- To view, visit https://gerrit.wikimedia.org/r/237433 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I8b443372c900238b1dc1c6586795a4e1833322ac Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/Wikibase Gerrit-Branch: wmf/1.26wmf22 Gerrit-Owner: Aude <aude.w...@gmail.com> Gerrit-Reviewer: Ricordisamoa <ricordisa...@openmailbox.org> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits