Bug #84475
closedValidation skipped for domain-record with circular relationship on itself on submitting nested form
100%
Description
When there is a circular relationship between domain-models like RootObject
-> 1:n -> Child
, where each Child
also has a property pointing back to its rootObject
, and submitting a form that consists of inputs for both RootObject
and its children, the validation of RootObject
may be skipped.
See the attached demo extension and below steps to reproduce.
This is due to reuse of the `GenericObjectValidator` instance for `rootObject` when validating the relation rootObject
of the Child
, where already accumulated $this->result
will be overridden with an empty Result
.
- install given ext.
- Place plugin "test" on a page
- open page in frontend, open "new RootObj"-Form, notice how saving with an empty title throws an error. Create a RootObj with nonempty title
- Open edit-form for the created rootObject, notice how clearing the title field and saving throws an error.
- In the backend, add a child to the rootObject via IRRE in list-module
- In the frontend, open edit-form of the rootObject again, notice the displayed inline form. Clear the title of the rootObject, and submit the form. Notice how there is no error displayed, the NotEmpty validation is skipped and the empty title persisted to database.
As stated above, stepping through the validation process, one notices, that the GenericObjectValidator
-instance for rootObject is reused when evaluating the rootObj
relation of the Child
, where validate()
resets the already present errors to an empty Result
in the first Line.
Patching this with $this->result = $this->result ?: new \TYPO3\CMS\Extbase\Error\Result();
fixes the problem.
Maybe a more clever solution incorporating the isValidatedAlready
check would be possible.
Files