[5.7] Backport #26486 - Fix FormRequest validation triggering twice #26731
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
As discussed in issue #25736 , after some changes introduced in 941c8c7 the
FormRequest
rules were being triggered twice.This issue was first addressed in the 5.8 branch by the PR #26419 which was backported to 5.7 in PR #26604 .
This fixes the issue in the Validator side, but when using the FormRequest this fix wasn't sufficient as every time the
getValidatorInstance()
method was called it creates a new validator instance which triggers the validation's rules again.If one uses the
validated()
method two instances would be created one when resolving the request, other when calling this method.Later another PR was sent to the 5.8 branch ( #26486 ) which caches the validator instance instantiated in the
FormRequest
object.This solves the problem as there will be only one Validator instance.
This PR backports the fix in PR #26486 to the 5.7 branch.