Silverstripe-framework: DBDate treats any date before the year 1000 as invalid

Created on 18 Jul 2019  路  6Comments  路  Source: silverstripe/silverstripe-framework

Affected Version

4.x

Description

DBDate::explodeDateString() will throw an InvalidArgumentException if it encounters a date with a year that鈥檚 less than 1000.

https://github.com/silverstripe/silverstripe-framework/blob/844d2ef134a344bca0e39ecc4c5d8bdd75de4171/src/ORM/FieldType/DBDate.php#L631-L639

Steps to Reproduce

  • Create a model with a field like 'TestDate' => 'Date'
  • Create a DateField form field, enter a date with a year less than 1000
  • Save the record

Marked as impact/low as using dates from that long ago is rare in web applications.

affectv4 changpatch efformedium impacmedium typbug

Most helpful comment

Feels like at least impact/medium, which is Unexpected behaviour, or broken functionality on less common usage flows.

All 6 comments

Marked as impact/low as using dates from that long ago is rare in web applications.

Until somebody builds a website for a museum 馃槃

Marked as impact/low as using dates from that long ago is rare in web applications.

Until somebody builds a website for a museum 馃槃

I've got a few clients who works with museums / art world and pretty sure they have some dates on some of their articles/stock pre 1000... Hoping this to be fixed soon-ish I was due to upgrade them to SS4 next month.

Wow! I knew museums referred to years before 1000, but I never thought they'd use dates, as well. Are there really things like 24 July 817?

Feels like at least impact/medium, which is Unexpected behaviour, or broken functionality on less common usage flows.

I haven't opened up the project in a while but from memory, I think we used dates to allow them to have control over chronological order of the records, so they're not essentially real dates.

Would it be ok if we used $parts[0] < 32 instead? You'd still have errors with the year 30, but... really... is that close enough? :P

Was this page helpful?
0 / 5 - 0 ratings