jenkins-bot has submitted this change and it was merged.
Change subject: Don't pass negative years to Language::sprintfDate
......................................................................
Don't pass negative years to Language::sprintfDate
Language::sprintfDate cannot handle negative years, so don't pass them.
Return an appropriate error instead.
Change-Id: I87ce19a32312bb7db0740b4daddb995132eef683
---
M ParserFunctions.i18n.php
M ParserFunctions_body.php
2 files changed, 16 insertions(+), 4 deletions(-)
Approvals:
Aaron Schulz: Looks good to me, approved
jenkins-bot: Verified
diff --git a/ParserFunctions.i18n.php b/ParserFunctions.i18n.php
index 2005126..6646ce7 100644
--- a/ParserFunctions.i18n.php
+++ b/ParserFunctions.i18n.php
@@ -13,6 +13,7 @@
'pfunc_time_error' => 'Error: Invalid time.',
'pfunc_time_too_long' => 'Error: Too many #time
calls.',
'pfunc_time_too_big' => 'Error: #time only supports
years up to 9999.',
+ 'pfunc_time_too_small' => 'Error: #time only supports
years from 0.',
'pfunc_rel2abs_invalid_depth' => 'Error: Invalid depth in
path: "$1" (tried to access a node above the root node).',
'pfunc_expr_stack_exhausted' => 'Expression error: Stack
exhausted.',
'pfunc_expr_unexpected_number' => 'Expression error:
Unexpected number.',
@@ -45,17 +46,26 @@
See also:
* {{msg-mw|Pfunc time too long}}
-* {{msg-mw|Pfunc time too big}}',
+* {{msg-mw|Pfunc time too big}}
+* {{msg-mw|Pfunc time too small}}',
'pfunc_time_too_long' => 'Used as error message.
See also:
* {{msg-mw|Pfunc time error}}
-* {{msg-mw|Pfunc time too big}}',
+* {{msg-mw|Pfunc time too big}}
+* {{msg-mw|Pfunc time too small}}',
'pfunc_time_too_big' => 'Used as error message.
See also:
* {{msg-mw|Pfunc time error}}
-* {{msg-mw|Pfunc time too long}}',
+* {{msg-mw|Pfunc time too long}}
+* {{msg-mw|Pfunc time too small}}',
+ 'pfunc_time_too_small' => 'Used as error message.
+
+See also:
+* {{msg-mw|Pfunc time error}}
+* {{msg-mw|Pfunc time too long}}
+* {{msg-mw|Pfunc time too big}}',
'pfunc_rel2abs_invalid_depth' => 'Used as error message. Parameters:
* $1 - full path',
'pfunc_expr_stack_exhausted' => 'Used as error message.
diff --git a/ParserFunctions_body.php b/ParserFunctions_body.php
index db8f729..967e833 100644
--- a/ParserFunctions_body.php
+++ b/ParserFunctions_body.php
@@ -471,7 +471,9 @@
if ( self::$mTimeChars > self::$mMaxTimeChars ) {
return '<strong class="error">' . wfMessage(
'pfunc_time_too_long' )->inContentLanguage()->escaped() . '</strong>';
} else {
- if ( $ts < 100000000000000 ) { // Language
can't deal with years after 9999
+ if ( $ts < 0 ) { // Language can't deal with BC
years
+ return '<strong class="error">' .
wfMessage( 'pfunc_time_too_small' )->inContentLanguage()->escaped() .
'</strong>';
+ } elseif ( $ts < 100000000000000 ) { //
Language can't deal with years after 9999
if ( $language !== '' &&
Language::isValidBuiltInCode( $language ) ) {
// use whatever language is
passed as a parameter
$langObject =
Language::factory( $language );
--
To view, visit https://gerrit.wikimedia.org/r/60079
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I87ce19a32312bb7db0740b4daddb995132eef683
Gerrit-PatchSet: 2
Gerrit-Project: mediawiki/extensions/ParserFunctions
Gerrit-Branch: master
Gerrit-Owner: Anomie <[email protected]>
Gerrit-Reviewer: Aaron Schulz <[email protected]>
Gerrit-Reviewer: Siebrand <[email protected]>
Gerrit-Reviewer: jenkins-bot
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits