Year 0000 event dates in MySQL crash ES when using search:populate
|Assignee:||Dan Gillean||% Done:|
|Target version:||Release 2.3.0|
|Google Code Legacy ID:||Tested version:||2.3|
1. Create a new archival description
2. Set the creation date to 0000-00-00
The archival description will not be present under browse / search subsequently (as the ES indexing failed).
Subsequently trying a php symfony search:populate from the CLI, results in the error:
index: /atom_cca/QubitInformationObject/3165262 caused MapperParsingException[failed to parse [dates.endDate]]; nested: MapperParsingException[failed to parse date field [0000-12-], tried both date format [dateOptionalTime], and timestamp number with locale ]; nested: IllegalArgumentException[Invalid format: "0000-12-" is malformed at "-"];
Our ES indexing code shouldn't choke when given a year 0000 date.
Ideally, we'd have a validator on dates that the user enters from the UI that denies them the ability to enter a year of 0000, since that year doesn't exist. But now we know there are clients out in the wild with these dates already in their data, so we'll have to make our indexing code more robust against this bug regardless.
I'll create a separate ticket for adding better date validation.
#3 Updated by Mike Gale almost 7 years ago
I tried thinking of a few workarounds, and the "best" one I could think of is: If we encounter a year 0000 date in the code here, then return null.
cal_days_in_month returns (bool)false if you pass it year 0000, so it doesn't really make sense as an end date at that point anyway.
#6 Updated by Mike Gale almost 7 years ago
Here's a better version of the patch, which renames the inaccurately named normalizeDateWithoutMonthOrYear to normalizeDateWithoutMonthOrDay and adds some extra comments.