-
Notifications
You must be signed in to change notification settings - Fork 11k
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
[ErrorException] strtotime(): Epoch doesn't fit in a PHP integer during date validation when exceeding current epoch. #40686
Comments
Is there interest in having this issue fixed? I'd be more than happy to contribute a fix. Proposed solution:
I'd like to point further that this isn't strictly a laravel related issue, other libraries face the same issues when calling the function. It's more to do with PHP than Laravel. Still having a fix for this would be great, as dates are indispensable :) |
Hmm, yeah it might be best to fix this. I think the try/catch can be a good first attempt and if that's refused, maybe the other solution. Can you maybe also give a really easy snippet with the validator to reproduce the issue? |
Hmm, just tried it with this and that works: Validator::make( [
'foo' => '12-2-4123',
], [
'foo' => 'date',
])->validate(); Can you provide the exact code that causes this? |
Sure thing :)
Despite this, I end up getting the error. |
I'll need the exact data and the exact rules |
I used |
Please post it like the example I shared. The exact code snippet with data. |
Entire stack shared here: https://flareapp.io/share/yPay4laP |
I'm sorry but I can still not reproduce it with the data you provided: Validator::make([
"_token" => "aAI55QeK5Lv1G1N0psaJuqN8OwQcuinF6eJkeOhy",
"name" => "qweqweqwe",
"phone" => "9888888888",
"email" => "iamtribulation@outlook.com",
"license_data" => "{}",
"user_id" => "1",
"valid_until" => "4123-12-04",
], [
"name" => "required|max:160",
"phone" => "nullable|digits:10",
"email" => "nullable|regex:/^.+@.+$/i|max:255",
"license_key" => "nullable|alpha_num|length:10",
"license_data" => "required|json",
"user_id" => "nullable|integer",
"created_at" => "sometimes|date",
"valid_until" => "required|date",
"updated_at" => "sometimes|date",
"deleted_at" => "nullable|date",
])->validate(); This passes for me on the latest Laravel 8 version. I'll need to redirect you to a support channel: |
@driesvints I'm sorry, but let me get this straight: Just because you're not able to replicate the issue, the issue doesn't exist? I've seen people face pitfalls with that attitude, but I'll trust your judgement with this one, I have no need for support. I'll make a PR regardless, it should be non-invasive, add in a bit of defensive programming against strtotime failing in case of an integer overflow during conversion. I invite you to close the PR if you think it's a waste of your time. |
@coderkoala more than welcome to send in the PR but I can't verify the issue if I can't reproduce it. |
@coderkoala is the machine you are running PHP on 32-bit? |
Description:
In cases of extreme oversight, there's a way to run into an exception if you try to put in some obscenely far away date, as it'd exceed PHP's integer size when trying to use strtotime.
Petition to have exception handling introduced to have a safety fallback.
Steps To Reproduce:
12-2-4123
.Problematic code area:
laravel\framework\src\Illuminate\Validation\Concerns\ValidatesAttributes.php:452
Workaround:
Validate client side, add a custom function for date fields until resolved.
The text was updated successfully, but these errors were encountered: