-
Notifications
You must be signed in to change notification settings - Fork 11.7k
[4.2] Fixed Carbon InvalidArgumentException When Using toArray or toJson On Unset Timestamps #6434
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
Conversation
An unset Timestamp in database would sometimes cause Carbon to fail: InvalidArgumentException in Carbon.php line 385: Unexpected data found. Proposed changes fix issue.
|
interesting |
|
Just to be clear, the issue crops up when a Timestamp field in the database has it's default value of 0000-00-00 00:00:00. (due to an insert such as DB::raw() ) |
|
Could you add a test please. |
Added nulled mysql timestamp
|
Added a test. |
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.
Please remove all trailing whitespace.
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.
Fixed.
|
removed whitespace
|
This test is still failing. |
|
A bit perplexed, because the change I made to the original code wouldn't set it negative -- so I imagine my test will fail without my change to the core code as well. I'll need to figure out why that's happening. I'm fairly new to Laravel so not sure exactly where to look. |
Fixed values to be correct according to default mysql timestamps
|
That negative you're getting is what I get with the old code. I did have an error in the test because of copy /paste syndrome, but that has been corrected. |
|
The test is failing because it isn't testing my changes made in |
|
Please rebase, and squash, if the tests are still failing, then it's 100% caused by your changes. |
|
I don't really agree with this change. If it's a date give it a valid date. I don't think it should just be missing from the resulting array. |
An unset Timestamp in database would sometimes cause Carbon to fail:
InvalidArgumentException in Carbon.php line 385: Unexpected data found.
Proposed changes fix issue.