-
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
$errors->has() is set to true when nothing has been submitted. #14615
Comments
You can also use |
@BrandonSurowiec Any insight as to why |
@adampatterson It was broken due to some code refactoring in one of the last two releases, then was fixed in this commit: #14409 So the next release 5.2.42 should restore the expected behavior. You can view issue #14396 for more information. |
@BrandonSurowiec Thanks! I was looking my mind. Our site builds on Docker so when it updated composer on its creation it had a newer version than our local env. then when we tried to debug got the same error all the time. Thanks again! |
ref #14396 |
I would like to start off by saying that I think a lot of what laravel does is Magic, That in mind I don't have a very good understanding of how everything is related.
My project recently started showing a general validation error on page load Whoops! Something went wrong!. Nothing had been submitted yet. I went back through composer nad removed Sentry for Laravel as I had just updated from the depreciated Raven version.
Same issue.
Now I probably copied this code from an example that was not from Version 5.2 but it worked fine.
I am using
ShareErrorsFromSession
in my HTTPKernel.When i was trying to debug this problem I used
I then went back in my code commits by weeks, and then months and still had the same issue.
I have since updated to use
count($errors) > 0
and everything is fine. Validation validates with my messages and is no longer showing the error on page load.But I started to wonder why this ended up happening.
$errors->has()
was returning true even though nothing was set. Again I could be doing something wrong before but from version 5.2 and 5.1 mentioned usingcount()
and version 5.0 didn't seem to touch that subject. I possibly found my solution here https://scotch.io/tutorials/laravel-form-validation#showing-errors-in-the-view But again this article is from 2014 but like is said, Everything worked and then it didn't.Really long story short, Is the change made here:https://github.com/laravel/framework/blame/5.2/src/Illuminate/Support/MessageBag.php#L118 the cause?
My guess is that no matter how far back I went in my code, the only thing that would have changed would be the Laravel framework update.
Thanks!
The text was updated successfully, but these errors were encountered: