Ricordisamoa has uploaded a new change for review.

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

Change subject: Skip some default callbacks when constructing SummaryFormatter
......................................................................

Skip some default callbacks when constructing SummaryFormatter

So the custom callback for 'VT:wikibase-entityid' gets called.

Reported by Ivan A. Krestinin:
https://www.wikidata.org/wiki/?diff=250029949&oldid=249601743

Change-Id: I8b443372c900238b1dc1c6586795a4e1833322ac
---
M repo/includes/WikibaseRepo.php
1 file changed, 8 insertions(+), 4 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Wikibase 
refs/changes/45/237345/1

diff --git a/repo/includes/WikibaseRepo.php b/repo/includes/WikibaseRepo.php
index 9b328fb..b5afa8b 100644
--- a/repo/includes/WikibaseRepo.php
+++ b/repo/includes/WikibaseRepo.php
@@ -797,7 +797,7 @@
         *
         * @return callable[]
         */
-       private function getFormatterFactoryCallbacksByType() {
+       private function getFormatterFactoryCallbacksByType( array $skip = 
array() ) {
                $callbacks = array();
 
                $valueFormatterBuilders = 
$this->newWikibaseValueFormatterBuilders();
@@ -812,15 +812,17 @@
                        $callbacks["PT:$key"] = $formatter;
                }
 
+               $callbacks = array_diff_key( $callbacks, array_flip( $skip ) );
+
                return $callbacks;
        }
 
        /**
         * @return OutputFormatValueFormatterFactory
         */
-       protected function newValueFormatterFactory() {
+       protected function newValueFormatterFactory( array $skip = array() ) {
                return new OutputFormatValueFormatterFactory(
-                       $this->getFormatterFactoryCallbacksByType(),
+                       $this->getFormatterFactoryCallbacksByType( $skip ),
                        $this->getDefaultLanguage(),
                        new LanguageFallbackChainFactory()
                );
@@ -879,7 +881,9 @@
                $idFormatter = new EntityIdPlainLinkFormatter( 
$this->getEntityContentFactory() );
 
                // Create a new ValueFormatterFactory, and override the 
formatter for entity IDs.
-               $valueFormatterFactory = $this->newValueFormatterFactory();
+               $valueFormatterFactory = $this->newValueFormatterFactory(
+                       array( 'PT:wikibase-item', 'PT:wikibase-property' )
+               );
                $valueFormatterFactory->setFormatterFactoryCallback(
                        'VT:wikibase-entityid',
                        function ( $format, FormatterOptions $options ) use ( 
$idFormatter ) {

-- 
To view, visit https://gerrit.wikimedia.org/r/237345
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: master
Gerrit-Owner: Ricordisamoa <ricordisa...@openmailbox.org>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to