Bug #49624

Domain Model validators are executed twice

Added by Adrian Föder about 8 years ago. Updated about 7 years ago.

Status:
Resolved
Priority:
Must have
Category:
Validation
Target version:
-
Start date:
2013-07-03
Due date:
% Done:

100%

Estimated time:
PHP Version:
Has patch:
No
Complexity:

Description

when having, for example, a

/**
 * @param SampleDto $sampleDto {fq class name abridged}
 */
public function sampleAction(SampleDto $sampleDto);

and an appropriate Validator for that model placed in Domain\Model\Validator\SampleDtoValidator (i.e. a Domain Model Validator in the sense of [‡]), the validation for it is fired twice on action invocation.

The argument's validator stack looks like the following then:

ConjunctionValidator:
    SampleDtoValidator
    ConjunctionValidator
        GenericObjectValidator
        SampleDtoValidator

as you can see, the SampleDtoValidator is there twice, that's why it's executed twice.

If, however, the Validator is not a Domain Model Validator, means, it's not placed in Domain\Model\Validator; and annotated manually like

/**
 * @param SampleDto $sampleDto {fq class name abridged}
 * @Flow\Validate("$sampleDto", type="Acme\Foobar\Somewhere\SampleDtoValidator")
 */
public function sampleAction(SampleDto $sampleDto);

...it's validated correctly only once.
The validator stack then looks like

ConjunctionValidator:
    SampleDtoValidator
    ConjunctionValidator
        GenericObjectValidator

as you can see, the "inner" conjunction validator only has a GenericObjectValidator now.

[‡] http://docs.typo3.org/flow/TYPO3FlowDocumentation/TheDefinitiveGuide/PartIII/Validation.html#validating-domain-models


Related issues

Related to TYPO3 Core - Bug #52607: Domain Model validators are executed twiceClosedAlexander Schnitzler2013-10-08

Actions
#1

Updated by Karsten Dambekalns about 8 years ago

  • Category set to Validation
#2

Updated by Bastian Waidelich almost 8 years ago

  • Status changed from New to Accepted
  • Assignee set to Bastian Waidelich

This might be related to #50585

#3

Updated by Helmut Hummel almost 8 years ago

Bastian Waidelich wrote:

This might be related to #50585

I think that is something different.

The issue in this case is, that

ValidatorResolver->buildMethodArgumentsValidatorConjunctions()
adds a domain model validator if present and
ValidatorResolver->buildBaseValidatorConjunction()
calls
ValidatorResolver->addCustomValidators()
which also adds a domain model validator if the class is found.

I suggest to remove the according code from

buildMethodArgumentsValidatorConjunctions

#4

Updated by Gerrit Code Review almost 8 years ago

  • Status changed from Accepted to Under Review

Patch set 1 for branch master has been pushed to the review server.
It is available at https://review.typo3.org/24174

#5

Updated by Gerrit Code Review almost 8 years ago

Patch set 2 for branch master has been pushed to the review server.
It is available at https://review.typo3.org/24174

#6

Updated by Gerrit Code Review almost 8 years ago

Patch set 3 for branch master has been pushed to the review server.
It is available at https://review.typo3.org/24174

#7

Updated by Markus Klein almost 8 years ago

Also an issue in TYPO3 CMS Extbase!!

#8

Updated by Gerrit Code Review over 7 years ago

Patch set 4 for branch master of project Packages/TYPO3.Flow has been pushed to the review server.
It is available at https://review.typo3.org/24174

#9

Updated by Gerrit Code Review over 7 years ago

Patch set 5 for branch master of project Packages/TYPO3.Flow has been pushed to the review server.
It is available at https://review.typo3.org/24174

#10

Updated by Gerrit Code Review about 7 years ago

Patch set 6 for branch master of project Packages/TYPO3.Flow has been pushed to the review server.
It is available at http://review.typo3.org/24174

#11

Updated by Gerrit Code Review about 7 years ago

Patch set 1 for branch 2.2 of project Packages/TYPO3.Flow has been pushed to the review server.
It is available at http://review.typo3.org/32437

#12

Updated by Gerrit Code Review about 7 years ago

Patch set 1 for branch 2.1 of project Packages/TYPO3.Flow has been pushed to the review server.
It is available at http://review.typo3.org/32438

#13

Updated by Helmut Hummel about 7 years ago

  • Status changed from Under Review to Resolved
  • % Done changed from 0 to 100

Also available in: Atom PDF