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 about 6 years ago. Updated almost 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 #1

Updated by Gerrit Code Review about 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

Actions #2

Updated by Gerrit Code Review about 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

Actions #3

Updated by Gerrit Code Review almost 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

Actions #4

Updated by Gerrit Code Review almost 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

Actions #5

Updated by Gerrit Code Review over 5 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

Actions #6

Updated by Riccardo De Contardi over 5 years ago

  • Category set to Extbase
Actions #7

Updated by Markus Klösges over 5 years ago

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.

Actions #8

Updated by Anja Leichsenring over 5 years ago

this is working now, I apply the patched extension to ease the testing for the next guy. Just download test(2).zip.

Actions #9

Updated by Gerrit Code Review over 5 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

Actions #10

Updated by Markus Klösges over 5 years ago

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

Updated by Gerrit Code Review over 5 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

Actions #12

Updated by Markus Klösges over 5 years ago

  • Status changed from Under Review to Resolved
Actions #13

Updated by Benni Mack almost 5 years ago

  • Status changed from Resolved to Closed
Actions #14

Updated by Stephan Großberndt over 4 years ago

  • Precedes Bug #89971: Extbase validation broken since merge of "58833: [BUGFIX] Keep existing validation errors for recursive domain relations" added
Actions

Also available in: Atom PDF