jenkins-bot has submitted this change and it was merged.
Change subject: Fix {{#property:}} calls for missing data on wikis with
LanguageConverter
......................................................................
Fix {{#property:}} calls for missing data on wikis with LanguageConverter
It was producing a list of all variant codes, because output strings are
empty for each variant, and the converter doesn't handle empty strings as
conversion entries correctly, having raw conversion code (except for the
surrounding -{ }-) output (like "sr:;sr-ec:;sr-el:;") as is.
Change-Id: Iada5fbd8736753622af734e3494d0b3fa0109f68
---
M client/includes/parserhooks/PropertyParserFunction.php
M client/tests/phpunit/includes/parserhooks/PropertyParserFunctionTest.php
2 files changed, 14 insertions(+), 3 deletions(-)
Approvals:
Aude: Looks good to me, approved
jenkins-bot: Verified
diff --git a/client/includes/parserhooks/PropertyParserFunction.php
b/client/includes/parserhooks/PropertyParserFunction.php
index bc9a53d..a143ad9 100644
--- a/client/includes/parserhooks/PropertyParserFunction.php
+++ b/client/includes/parserhooks/PropertyParserFunction.php
@@ -80,11 +80,13 @@
*/
public function processRenderedArray( $textArray ) {
// We got arrays, so they must have already checked that
variants are being used.
- $text = '-{';
+ $text = '';
foreach ( $textArray as $variantCode => $variantText ) {
$text .= "$variantCode:$variantText;";
}
- $text .= '}-';
+ if ( $text !== '' ) {
+ $text = '-{' . $text . '}-';
+ }
return $text;
}
@@ -161,7 +163,13 @@
foreach ( $variants as $variantCode ) {
$variantLanguage = \Language::factory( $variantCode );
- $textArray[$variantCode] = $this->renderInLanguage(
$propertyLabel, $variantLanguage );
+ $variantText = $this->renderInLanguage( $propertyLabel,
$variantLanguage );
+ // LanguageConverter doesn't handle empty strings
correctly, and it's more difficult
+ // to fix the issue there, as it's using empty string
as a special value.
+ // Also keeping the ability to check a missing property
with {{#if: }} is another reason.
+ if ( $variantText !== '' ) {
+ $textArray[$variantCode] = $variantText;
+ }
}
return $textArray;
diff --git
a/client/tests/phpunit/includes/parserhooks/PropertyParserFunctionTest.php
b/client/tests/phpunit/includes/parserhooks/PropertyParserFunctionTest.php
index 6b49bbd..655e203 100644
--- a/client/tests/phpunit/includes/parserhooks/PropertyParserFunctionTest.php
+++ b/client/tests/phpunit/includes/parserhooks/PropertyParserFunctionTest.php
@@ -95,6 +95,9 @@
'zh-cn' => 'fo<ob>ar',
'zh-tw' => 'FO<OB>AR',
), '-{zh-cn:fo<ob>ar;zh-tw:FO<OB>AR;}-'
),
+ // Don't create "-{}-" for empty input,
+ // to keep the ability to check a missing property with
{{#if: }}.
+ array( \Parser::OT_HTML, array(), '' ),
);
}
--
To view, visit https://gerrit.wikimedia.org/r/90636
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: Iada5fbd8736753622af734e3494d0b3fa0109f68
Gerrit-PatchSet: 2
Gerrit-Project: mediawiki/extensions/Wikibase
Gerrit-Branch: master
Gerrit-Owner: Liangent <[email protected]>
Gerrit-Reviewer: Aude <[email protected]>
Gerrit-Reviewer: Daniel Kinzler <[email protected]>
Gerrit-Reviewer: GWicke <[email protected]>
Gerrit-Reviewer: Jeroen De Dauw <[email protected]>
Gerrit-Reviewer: jenkins-bot
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits