Skip to content

Don’t unlocalize month names without letters - #167

Open
lucaswerkmeister wants to merge 1 commit into
masterfrom
MonthNameUnlocalizer
Open

Don’t unlocalize month names without letters#167
lucaswerkmeister wants to merge 1 commit into
masterfrom
MonthNameUnlocalizer

Conversation

@lucaswerkmeister

Copy link
Copy Markdown
Member

The case of purely-numeric month names (ko) is already handled, because PHP implicitly turns such array keys into integers, and then they fail the existing is_string() check. But MonthNameUnlocalizer would still unlocalize month names that only consisted of numbers and punctuation (cs), which isn’t right either; add another check to prevent that.

Bug: T325988

The case of purely-numeric month names (ko) is already handled, because
PHP implicitly turns such array keys into integers, and then they fail
the existing is_string() check. But MonthNameUnlocalizer would still
unlocalize month names that only consisted of numbers and punctuation
(cs), which isn’t right either; add another check to prevent that.

Bug: T325988
@@ -46,6 +46,10 @@ public function unlocalize( $date ) {
if ( !is_string( $search ) ) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This check is now redundant, isn't it? The key is either a string or an integer (that cannot be matched with the regex).

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess we could remove it and use (string)$search below, but to me that seems less clear (and probably also slightly slower). I’d prefer to keep the separate condition.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK, let's keep it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants