-
Notifications
You must be signed in to change notification settings - Fork 892
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Validate datetime for version. #2249
Conversation
751d1db
to
62dc97a
Compare
I've debated on if the appropriate place to put this is as a runtime check within initialization the migration, vs within the Thoughts?
I'm curious what legacy reason beyond test harnesses exist to support I do like the approach here of only validating that the version integer is a valid date string, and not putting limits on what the allowed range of dates is, as I think that has the potential to be limiting for less value. |
if (!$version || $length === 14) { | ||
return; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A follow-up here would be to validating that the various pieces of the string are all valid, e.g. that don't have 00
or 13
for MM
, potentially including also complexity in not allowing invalid dates (e.g. no 30
for MM == 02
).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure, but then it wouldnt fit in a "minor" release probably as people could have existing invalid ones that are valid in range (sorting).
So for now I would like to keep it as is, but in the next major we could try to limit it to a more sane value in general.
could be a follow up if you want to further narrow the possible valid values. |
I pushed the update, was a quick write-up. |
Easy enough to move this check to somewhere else if we decide we need to down the road without breaking BC I think. I do think this check does break BC though in that it's possible to bypass the date version naming scheme that phinx uses, and just use any number you wanted (e.g. having a counter), though you'd just have to manually create each migration. Not sure if anyone is doing that, so probably fine to just merge it into the next |
Resolves #2248
For legacy reasons and BC on the test harnesses I allowed the 0 to pass for now as well.
I think thats fair since most mistakes would happen with actual datetime values.