jenkins-bot has submitted this change and it was merged.

Change subject: MwTimeIsoParser should not unlocalize based on empty messages
......................................................................


MwTimeIsoParser should not unlocalize based on empty messages

Bug: T139509
Change-Id: I0dd5def77b1407de852b0e57bc4c29afc9f08c9e
---
M repo/includes/Parsers/MwTimeIsoParser.php
M repo/tests/phpunit/includes/Parsers/MwTimeIsoParserTest.php
2 files changed, 12 insertions(+), 1 deletion(-)

Approvals:
  Hoo man: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/repo/includes/Parsers/MwTimeIsoParser.php 
b/repo/includes/Parsers/MwTimeIsoParser.php
index 973ab85..04ace74 100644
--- a/repo/includes/Parsers/MwTimeIsoParser.php
+++ b/repo/includes/Parsers/MwTimeIsoParser.php
@@ -148,6 +148,11 @@
         */
        private function parseFromOutputString( Language $lang, $value, 
$precision, $msgKey ) {
                $msgText = $lang->getMessage( $msgKey );
+
+               if ( strpos( $msgText, '$1' ) === false || $msgText === '$1' ) {
+                       return null;
+               }
+
                $isBceMsg = $this->isBceMsg( $msgKey );
                $msgRegexp = $this->getRegexpFromMessageText( $msgText );
 
diff --git a/repo/tests/phpunit/includes/Parsers/MwTimeIsoParserTest.php 
b/repo/tests/phpunit/includes/Parsers/MwTimeIsoParserTest.php
index 999eb50..ad3400f 100644
--- a/repo/tests/phpunit/includes/Parsers/MwTimeIsoParserTest.php
+++ b/repo/tests/phpunit/includes/Parsers/MwTimeIsoParserTest.php
@@ -99,7 +99,13 @@
                        // With $1 in the PLURAL case
                        'wikibase-time-precision-BCE-century' => 
'{{PLURAL:$1|$1 one|$1 more|$1 evenmore}} precision-BCE-century',
                        // A random template in the message
-                       'wikibase-time-precision-10annum' => '$1 
precision-10annum{{PLURAL:$1||s}} {{dummy|1|2|3}}'
+                       'wikibase-time-precision-10annum' => '$1 
precision-10annum{{PLURAL:$1||s}} {{dummy|1|2|3}}',
+
+                       // Invalid messages
+                       'wikibase-time-precision-BCE-10annum' => '$1',
+                       'wikibase-time-precision-BCE-millennium' => '-',
+                       'wikibase-time-precision-BCE-annum' => '',
+                       'wikibase-time-precision-BCE-Gannum' => null,
                ];
        }
 

-- 
To view, visit https://gerrit.wikimedia.org/r/297754
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: I0dd5def77b1407de852b0e57bc4c29afc9f08c9e
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Wikibase
Gerrit-Branch: master
Gerrit-Owner: Thiemo Mättig (WMDE) <[email protected]>
Gerrit-Reviewer: Hoo man <[email protected]>
Gerrit-Reviewer: jenkins-bot <>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to