Project

General

Profile

Actions

Bug #84475

closed

Validation skipped for domain-record with circular relationship on itself on submitting nested form

Added by Markus Klösges over 6 years ago. Updated over 5 years ago.

Status:
Closed
Priority:
Must have
Assignee:
-
Category:
Extbase
Target version:
-
Start date:
2018-03-19
Due date:
% Done:

100%

Estimated time:
TYPO3 Version:
9
PHP Version:
Tags:
Complexity:
Is Regression:
Sprint Focus:

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.

Steps to reproduce:
  1. install given ext.
  2. Place plugin "test" on a page
  3. open page in frontend, open "new RootObj"-Form, notice how saving with an empty title throws an error. Create a RootObj with nonempty title
  4. Open edit-form for the created rootObject, notice how clearing the title field and saving throws an error.
  5. In the backend, add a child to the rootObject via IRRE in list-module
  6. 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

test.zip (530 KB) test.zip Test extension to reproduce Markus Klösges, 2018-03-19 13:34
local_history.patch (995 Bytes) local_history.patch Patch for test-ext to fix domain-relation. Markus Klösges, 2018-10-28 19:25
test (2).zip (521 KB) test (2).zip Anja Leichsenring, 2018-11-02 10:07

Related issues 1 (0 open1 closed)

Precedes TYPO3 Core - Bug #89971: Extbase validation broken since merge of "58833: [BUGFIX] Keep existing validation errors for recursive domain relations"Rejected

Actions
Actions

Also available in: Atom PDF