jenkins-bot has submitted this change and it was merged. Change subject: Use a proper StringParser instead of NullParser for StringValues. ......................................................................
Use a proper StringParser instead of NullParser for StringValues. So far, we had a NullParser defiend for parsing values for the commonsMedia, url, and string data types. Since NullParser always returns an UnknownValue, this setup was not actually usable by the frontend, causing special case handling to be implemented in JS. To avoid this, we can now use the new StringParser. Using StringParser also allows us to apply unicode normalization to all incoming string values. This restores what was already implemented with I226f0dff9. Bug: T104873 Change-Id: Ifefc996e5fe8d498d4014060086ec1f8a673ee2f --- M repo/WikibaseRepo.datatypes.php 1 file changed, 9 insertions(+), 6 deletions(-) Approvals: JanZerebecki: Looks good to me, approved jenkins-bot: Verified diff --git a/repo/WikibaseRepo.datatypes.php b/repo/WikibaseRepo.datatypes.php index 431673e..390222f 100644 --- a/repo/WikibaseRepo.datatypes.php +++ b/repo/WikibaseRepo.datatypes.php @@ -24,11 +24,12 @@ use DataValues\Geo\Parsers\GlobeCoordinateParser; use ValueFormatters\FormatterOptions; -use ValueParsers\NullParser; use ValueParsers\QuantityParser; +use ValueParsers\StringParser; use ValueParsers\ValueParser; use Wikibase\Lib\EntityIdValueParser; use Wikibase\Lib\Parsers\TimeParserFactory; +use Wikibase\Lib\WikibaseStringValueNormalizer; use Wikibase\Parsers\MonolingualTextParser; use Wikibase\Repo\WikibaseRepo; @@ -50,8 +51,10 @@ return new EntityIdValueParser( $repo->getEntityIdParser() ); }; - $newNullParser = function( ValueParsers\ParserOptions $options ) { - return new NullParser(); + $newStringParser = function( ValueParsers\ParserOptions $options ) { + $repo = WikibaseRepo::getDefaultInstance(); + $normalizer = new WikibaseStringValueNormalizer( $repo->getStringNormalizer() ); + return new StringParser( $normalizer ); }; return array( @@ -60,7 +63,7 @@ $factory = WikibaseRepo::getDefaultValidatorBuilders(); return $factory->buildStringValidators(); }, - 'parser-factory-callback' => $newNullParser, //TODO: use StringParser + 'parser-factory-callback' => $newStringParser, 'formatter-factory-callback' => function( $format, FormatterOptions $options ) { $factory = WikibaseRepo::getDefaultFormatterBuilders(); return $factory->newCommonsMediaFormatter( $format, $options ); @@ -112,7 +115,7 @@ $factory = WikibaseRepo::getDefaultValidatorBuilders(); return $factory->buildStringValidators(); }, - 'parser-factory-callback' => $newNullParser, //TODO: use StringParser + 'parser-factory-callback' => $newStringParser, 'formatter-factory-callback' => function( $format, FormatterOptions $options ) { return null; // rely on formatter for string value type }, @@ -136,7 +139,7 @@ $factory = WikibaseRepo::getDefaultValidatorBuilders(); return $factory->buildUrlValidators(); }, - 'parser-factory-callback' => $newNullParser, //TODO: use StringParser + 'parser-factory-callback' => $newStringParser, 'formatter-factory-callback' => function( $format, FormatterOptions $options ) { $factory = WikibaseRepo::getDefaultFormatterBuilders(); return $factory->newUrlFormatter( $format, $options ); -- To view, visit https://gerrit.wikimedia.org/r/236545 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: merged Gerrit-Change-Id: Ifefc996e5fe8d498d4014060086ec1f8a673ee2f Gerrit-PatchSet: 2 Gerrit-Project: mediawiki/extensions/Wikibase Gerrit-Branch: master Gerrit-Owner: Daniel Kinzler <daniel.kinz...@wikimedia.de> Gerrit-Reviewer: Adrian Lang <adrian.he...@wikimedia.de> Gerrit-Reviewer: Aude <aude.w...@gmail.com> Gerrit-Reviewer: JanZerebecki <jan.wikime...@zerebecki.de> Gerrit-Reviewer: Jeroen De Dauw <jeroended...@gmail.com> Gerrit-Reviewer: Jonas Kress (WMDE) <jonas.kr...@wikimedia.de> Gerrit-Reviewer: Thiemo Mättig (WMDE) <thiemo.maet...@wikimedia.de> Gerrit-Reviewer: jenkins-bot <> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits