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
Updated by Gerrit Code Review over 6 years ago
- Status changed from New to Under Review
Patch set 1 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/56677
Updated by Gerrit Code Review over 6 years ago
Patch set 2 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/56677
Updated by Gerrit Code Review over 6 years ago
Patch set 3 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/56677
Updated by Gerrit Code Review over 6 years ago
Patch set 4 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/56677
Updated by Gerrit Code Review about 6 years ago
Patch set 5 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/56677
Updated by Markus Klösges about 6 years ago
- File local_history.patch local_history.patch added
The test-extension has an error in the db-mapping setup. The relation Child -> rootObject is not correctly populated due to a casing-mismatch. Please apply the attached patch to have a correct test-setup.
Without a correct property name for the relations value the validator will be called with a null value for the referenced `rootObject`, as the mapper can't inject the value into the `Child`. As `null` is a valid value for the ObjectValidator, it will then pass validation. I don't know how to circumvent this. But as this is a setup error in the domain-related php-classes think its ok if validation is not producing the expected results then.
Updated by Anja Leichsenring about 6 years ago
- File test (2).zip test (2).zip added
this is working now, I apply the patched extension to ease the testing for the next guy. Just download test(2).zip.
Updated by Gerrit Code Review about 6 years ago
Patch set 1 for branch TYPO3_8-7 of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/58833
Updated by Markus Klösges about 6 years ago
- Status changed from Under Review to Resolved
- % Done changed from 0 to 100
Applied in changeset 565764486d13c18fd526a428e983388b2bc36cb5.
Updated by Gerrit Code Review about 6 years ago
- Status changed from Resolved to Under Review
Patch set 2 for branch TYPO3_8-7 of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/58833
Updated by Markus Klösges about 6 years ago
- Status changed from Under Review to Resolved
Applied in changeset 1e462fbf8f28329686aa136f21b739438c9e6bcd.
Updated by Stephan Großberndt almost 5 years ago
- Precedes Bug #89971: Extbase validation broken since merge of "58833: [BUGFIX] Keep existing validation errors for recursive domain relations" added