Bug #9862

Base validators are built incorrectly

Added by Karsten Dambekalns almost 5 years ago. Updated almost 5 years ago.

Status:Resolved Start date:2010-09-21
Priority:Must have Due date:
Assigned To:Karsten Dambekalns % Done:

100%

Category:Validation
Target version:TYPO3 Flow Base Distribution - 1.0 alpha 12
PHP Version: Complexity:
Has patch: Affected Flow version:

Description

When a base validator is built, any property that
  • has a @validate annotations
  • or holds a class for which a base validator exists
    gets a validator attached. Then any custom validator for a class is added.

Currently this is not working as expected. Consider this example:

class Node {

    /**
     * Workspace this node is contained in
     *
     * @var \F3\TYPO3CR\Domain\Model\Workspace
     */
    protected $workspace;

    /**
     * Identifier of this node which is unique within its workspace
     *
     * @var string
     * @validate uuid
     */
    protected $identifier;

This will check the $identifier to be an UUID and it will also check validity on $workspace (if the validator for that is not NULL). But if the uuid validation annotation is removed the $workspace property will no longer be validated as well.

Associated revisions

Revision 48baedce
Added by Karsten Dambekalns almost 5 years ago

[+BUGFIX] FLOW3 (Validation): Fix building of base validators

The conjunction validators built for base validation of models did not
behave correctly, validation of contained objects was not added at all,
if no @validate annotation was found (#9862).

In addition validators for nested objects (A contains B which contains
A) could not be built due to ending up in endless recursion (#9855).

Change-Id: Id62828271312adb5c8e21c000a061b008b4596ec
Fixes: #9855
Fixes: #9862

Revision 905f0e34
Added by Karsten Dambekalns almost 5 years ago

[+BUGFIX] FLOW3 (Validation): Only build base validator for prototypes

The ValidatorResolver built a base validator conjunction for all
properties in a class, but it should do that only for prototypes (and
thus skip things like the object manager).

Change-Id: I386a06199c7d63cf152389a9463dc54451a7f575
Fixes: #9862

History

#1 Updated by Karsten Dambekalns almost 5 years ago

  • Status changed from Needs Feedback to Accepted

#2 Updated by Karsten Dambekalns almost 5 years ago

  • Status changed from Accepted to Under Review

#3 Updated by Karsten Dambekalns almost 5 years ago

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

#4 Updated by Sebastian Kurfuerst almost 5 years ago

  • Status changed from Resolved to Accepted
  • % Done changed from 100 to 50

Hey Karsten,

we have just found a severe regression with this patch:

In the BlogExample, the "Blog" object holds a reference to the "PostRepository" -- and now, a validator is built for the PostRepository, even though it is a SINGLETON object.

This should never happen for singletons IMHO, they should not be mappable at all by the propery mapper, but only injected via DI.

Greets,
Bastian, Andi and Sebastian :-)

#5 Updated by Karsten Dambekalns almost 5 years ago

This should never happen for singletons IMHO, they should not be mappable at all by the propery mapper, but only injected via DI.

Well, is it singletons or should validators only be built for entities and value objects?

#6 Updated by Sebastian Kurfuerst almost 5 years ago

I'd say only for entities / value objects.

#7 Updated by Karsten Dambekalns almost 5 years ago

  • Status changed from Accepted to Under Review

#8 Updated by Karsten Dambekalns almost 5 years ago

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

Also available in: Atom PDF