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
custom request execute twice if all the rules success passed, with laravel v5.8.26 + dingo v2.2.4 or v2.3.0 #1668
Comments
This may be related to a known issue whereby a controller actually gets instantiated twice. Can you do a test and instead of typehinting the request class in the method args, use a normal request, and instead do this inside the body: app(TestRequest); And let me know if the result is the same or not. |
Wanted to chime in that we're affected by this, as well. Our I suspect it might be related to laravel/framework#26419. |
Would you guys be able to post some code snippets of your controllers ? I myself am using the FormRequests in a couple of different ways, but the issue doesn't seem to happen for me, so I want more sample data to work with. Also would you mind trying the above suggestion? |
@specialtactics Downgrading to 2.2.3 solved it for me, no other code changes were required. 🐛 🐛 🐛 |
@specialtactics I'll see what I can do. Ours is a bit complex; I'll see if I can narrow it down to a minimal reproducible example. OP posted some code, as well. |
In dingo 2.2.4 this code was added in the // Validate FormRequest after resolving
$this->app->afterResolving(ValidatesWhenResolved::class, function ($resolved) {
$resolved->validateResolved();
}); This code is also in laravel's framework So if you have To fix this you will need to remain on 2.2.3 version or if you really want to update to a newer version you can override the |
@luisdc05 is spot on, I can confirm that's precisely what's going on... |
Would really appreciate if you guys gave me your version of Laravel and a code sample, for my applications the behaviour is much different to what you describe. I am not saying you're wrong, but it's just very difficult to investigate this without further to go on. |
Hello! Does this repo help? Laravel: 5.8.38 Just hit the |
Thank you so much @luisdc05 I will investigate this over the weekend, and post an update. |
when I change my FoundationServiceProvider and it not work too. |
I get this problem too, is there any solution , i don't want to downgrading my laravel 6.5 |
@specialtactics any news about this ? |
Hey everyone Sorry, I've been away due to the holidays. I'm very keen to fix this bug ASAP, so I devoted some time today to testing. I've commented out that code that's been pointed out, and I do believe it should return things to normal. PR Merged here: #1698 To elaborate, I set up a custom request just to test one attribute "called test", these are the results;
This is a vert tricky regression, if anyone could try and write unit tests to prevent this form happening, that would be great ! |
Description:
A custom request class in Laravel will validate before entering a controller action, but all methods in the custom request will be executed twice if all the verification rules are passed.
if some rules got error, executed only once.
this is a bug caused by dingo/api, v2.2.3 is work. v2.2.4 and v2.3.0 are all meet this bug.
refer link:
laravel/framework#28972
Steps To Reproduce:
Example Controller
Example Custom Request:
for the example code above, if all the verification rules passed, logs like below:
if some verification rules fails, logs like below:
The text was updated successfully, but these errors were encountered: