Lucas_Werkmeister_WMDE added a comment.
> The abbreviated month is always a number followed by a dot. Therefore, if
the input is in the DD. MM. YYYY format, the day may be replaced instead of the
month (since during replacement string is scanned left-to-right).
> For example, `5. 4. 1891` (April 5th, 1891) can be replaced as both `5.
April 1891` (parsed correctly) and `May 4. 1891` (parsed with day and month
swapped). **In general, this depends on which comes first.**
And Wikibase tries to make the longer replacements first:
name=MonthNameUnlocalizer:__construct()
// Order search strings from longest to shortest
uksort( $this->replacements, static function ( $a, $b ) {
return strlen( $b ) - strlen( $a );
} );
But in the case of `5.` vs. `4.`, the length is the same; since PHP 8.0,
uksort <https://www.php.net/manual/en/function.uksort.php> retains the original
order in that case, but in production (PHP 7.4, until T319432
<https://phabricator.wikimedia.org/T319432>) the sort is not stable and may
apparently swap the dates around arbitrarily. I tried it out in `shell.php`
(`$sorted = ( new \Wikibase\Repo\Parsers\MediaWikiMonthNameProvider()
)->getMonthNumbers( 'cs' ); uksort( $sorted, fn( $a, $b ) => strlen( $b ) -
strlen( $a ) ); $sorted`), and the result seems to be at least consistent
across calls (including across different PHP processes) – 11, 10, 12, 9, 8, 7,
5, 4, 3, 2, 1, 6. But still, this is pretty horrible.
TASK DETAIL
https://phabricator.wikimedia.org/T325988
EMAIL PREFERENCES
https://phabricator.wikimedia.org/settings/panel/emailpreferences/
To: Lucas_Werkmeister_WMDE
Cc: Lucas_Werkmeister_WMDE, Aklapper, matej_suchanek, Astuthiodit_1,
karapayneWMDE, Invadibot, maantietaja, ItamarWMDE, Akuckartz, Nandana, Lahi,
Gq86, GoranSMilovanovic, QZanden, LawExplorer, _jensen, rosalieper, Scott_WUaS,
Wikidata-bugs, aude, Mbch331
_______________________________________________
Wikidata-bugs mailing list -- [email protected]
To unsubscribe send an email to [email protected]