Thiemo Mättig (WMDE) has uploaded a new change for review.
https://gerrit.wikimedia.org/r/121022
Change subject: YearTimeParser: Fix regex checking for "contains" instead of
"is number"
......................................................................
YearTimeParser: Fix regex checking for "contains" instead of "is number"
Change-Id: I7226b272e7f3831f16a4c17c049adb9074263ec9
---
M lib/includes/parsers/YearTimeParser.php
M lib/tests/phpunit/parsers/YearTimeParserTest.php
2 files changed, 4 insertions(+), 4 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Wikibase
refs/changes/22/121022/1
diff --git a/lib/includes/parsers/YearTimeParser.php
b/lib/includes/parsers/YearTimeParser.php
index 613537a..6a58263 100644
--- a/lib/includes/parsers/YearTimeParser.php
+++ b/lib/includes/parsers/YearTimeParser.php
@@ -58,7 +58,7 @@
protected function stringParse( $value ) {
list( $sign, $year ) = $this->eraParser->parse( $value );
- if( !preg_match( '/\d+/', $year ) ) {
+ if( !preg_match( '/^\d+$/', $year ) ) {
throw new ParseException( 'Failed to parse year: ' .
$value );
}
diff --git a/lib/tests/phpunit/parsers/YearTimeParserTest.php
b/lib/tests/phpunit/parsers/YearTimeParserTest.php
index 55d50aa..1623739 100644
--- a/lib/tests/phpunit/parsers/YearTimeParserTest.php
+++ b/lib/tests/phpunit/parsers/YearTimeParserTest.php
@@ -117,10 +117,10 @@
/**
* @expectedException \ValueParsers\ParseException
- * @expectedExceptionMessage Failed to parse year: just invalid
+ * @expectedExceptionMessage Failed to parse year: ju5t 1nval1d
*/
public function testParseExceptionMessage() {
- $this->getInstance()->parse( 'just invalid' );
+ $this->getInstance()->parse( 'ju5t 1nval1d' );
}
-}
\ No newline at end of file
+}
--
To view, visit https://gerrit.wikimedia.org/r/121022
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I7226b272e7f3831f16a4c17c049adb9074263ec9
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Wikibase
Gerrit-Branch: master
Gerrit-Owner: Thiemo Mättig (WMDE) <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits