Aude has uploaded a new change for review.
https://gerrit.wikimedia.org/r/252507
Change subject: Apply language fallback on Special:ConstraintReport
......................................................................
Apply language fallback on Special:ConstraintReport
Bug: T118376
Change-Id: I308a7f5ec8dccb9b15e368d8fadd80080048dbd1
---
M specials/SpecialConstraintReport.php
M tests/phpunit/Specials/SpecialConstraintReportTest.php
2 files changed, 22 insertions(+), 12 deletions(-)
git pull
ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/WikibaseQualityConstraints
refs/changes/07/252507/1
diff --git a/specials/SpecialConstraintReport.php
b/specials/SpecialConstraintReport.php
index 618c501..d0ee747 100644
--- a/specials/SpecialConstraintReport.php
+++ b/specials/SpecialConstraintReport.php
@@ -11,8 +11,6 @@
use Wikibase\DataModel\Services\EntityId\EntityIdFormatter;
use HTMLForm;
use Wikibase\DataModel\Services\Lookup\EntityLookup;
-use Wikibase\DataModel\Services\Lookup\LanguageLabelDescriptionLookup;
-use Wikibase\DataModel\Services\Lookup\TermLookup;
use Wikibase\Lib\OutputFormatValueFormatterFactory;
use Wikibase\Lib\SnakFormatter;
use DataValues;
@@ -27,6 +25,7 @@
use Wikibase\DataModel\Entity\ItemId;
use Wikibase\DataModel\Entity\PropertyId;
use Wikibase\Lib\Store\EntityTitleLookup;
+use Wikibase\Lib\Store\LanguageFallbackLabelDescriptionLookupFactory;
use Wikibase\Repo\EntityIdHtmlLinkFormatterFactory;
use Wikibase\Repo\EntityIdLabelFormatterFactory;
use Wikibase\Repo\WikibaseRepo;
@@ -101,10 +100,10 @@
return new self(
$wikibaseRepo->getEntityLookup(),
- $wikibaseRepo->getTermLookup(),
$wikibaseRepo->getEntityTitleLookup(),
new EntityIdLabelFormatterFactory(),
$wikibaseRepo->getEntityIdHtmlLinkFormatterFactory(),
+
$wikibaseRepo->getLanguageFallbackLabelDescriptionLookupFactory(),
$wikibaseRepo->getEntityIdParser(),
$wikibaseRepo->getValueFormatterFactory(),
$constraintReportFactory->getConstraintChecker()
@@ -113,20 +112,20 @@
/**
* @param EntityLookup $entityLookup
- * @param TermLookup $termLookup
* @param EntityTitleLookup $entityTitleLookup
* @param EntityIdLabelFormatterFactory $entityIdLabelFormatterFactory
* @param EntityIdHtmlLinkFormatterFactory
$entityIdHtmlLinkFormatterFactory
+ * @param LanguageFallbackLabelDescriptionLookupFactory
$fallbackLabelDescLookupFactory
* @param EntityIdParser $entityIdParser
* @param OutputFormatValueFormatterFactory $valueFormatterFactory
* @param DelegatingConstraintChecker $constraintChecker
*/
public function __construct(
EntityLookup $entityLookup,
- TermLookup $termLookup,
EntityTitleLookup $entityTitleLookup,
EntityIdLabelFormatterFactory $entityIdLabelFormatterFactory,
EntityIdHtmlLinkFormatterFactory
$entityIdHtmlLinkFormatterFactory,
+ LanguageFallbackLabelDescriptionLookupFactory
$fallbackLabelDescLookupFactory,
EntityIdParser $entityIdParser,
OutputFormatValueFormatterFactory $valueFormatterFactory,
DelegatingConstraintChecker $constraintChecker
@@ -137,13 +136,24 @@
$this->entityTitleLookup = $entityTitleLookup;
$this->entityIdParser = $entityIdParser;
- $formatterOptions = new FormatterOptions();
- $formatterOptions->setOption( SnakFormatter::OPT_LANG,
$this->getLanguage()->getCode() );
- $this->dataValueFormatter =
$valueFormatterFactory->getValueFormatter( SnakFormatter::FORMAT_HTML,
$formatterOptions );
+ $language = $this->getLanguage();
- $labelLookup = new LanguageLabelDescriptionLookup( $termLookup,
$this->getLanguage()->getCode() );
- $this->entityIdLabelFormatter =
$entityIdLabelFormatterFactory->getEntityIdFormatter( $labelLookup );
- $this->entityIdLinkFormatter =
$entityIdHtmlLinkFormatterFactory->getEntityIdFormatter( $labelLookup );
+ $formatterOptions = new FormatterOptions();
+ $formatterOptions->setOption( SnakFormatter::OPT_LANG,
$language->getCode() );
+ $this->dataValueFormatter =
$valueFormatterFactory->getValueFormatter(
+ SnakFormatter::FORMAT_HTML,
+ $formatterOptions
+ );
+
+ $labelLookup =
$fallbackLabelDescLookupFactory->newLabelDescriptionLookup( $language );
+
+ $this->entityIdLabelFormatter =
$entityIdLabelFormatterFactory->getEntityIdFormatter(
+ $labelLookup
+ );
+
+ $this->entityIdLinkFormatter =
$entityIdHtmlLinkFormatterFactory->getEntityIdFormatter(
+ $labelLookup
+ );
$this->constraintChecker = $constraintChecker;
}
diff --git a/tests/phpunit/Specials/SpecialConstraintReportTest.php
b/tests/phpunit/Specials/SpecialConstraintReportTest.php
index 04eeb54..93ba09e 100644
--- a/tests/phpunit/Specials/SpecialConstraintReportTest.php
+++ b/tests/phpunit/Specials/SpecialConstraintReportTest.php
@@ -73,10 +73,10 @@
return new SpecialConstraintReport(
$wikibaseRepo->getEntityLookup(),
- $wikibaseRepo->getTermLookup(),
$wikibaseRepo->getEntityTitleLookup(),
new EntityIdLabelFormatterFactory(),
$wikibaseRepo->getEntityIdHtmlLinkFormatterFactory(),
+
$wikibaseRepo->getLanguageFallbackLabelDescriptionLookupFactory(),
$wikibaseRepo->getEntityIdParser(),
$wikibaseRepo->getValueFormatterFactory(),
$constraintReportFactory->getConstraintChecker()
--
To view, visit https://gerrit.wikimedia.org/r/252507
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I308a7f5ec8dccb9b15e368d8fadd80080048dbd1
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/WikibaseQualityConstraints
Gerrit-Branch: master
Gerrit-Owner: Aude <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits