Bug #70017
closedDomain object validation ignored, when object has property of the same type
100%
Description
When an object has a property, that is of the same type as the current object (e.g. if object can have parent objects of the same type), domain object validation seems to be ignored completely.
Description in short:
Domain model is as following (simplyfied):
class Testmodel extends \TYPO3\CMS\Extbase\DomainObject\AbstractEntity { /** * A required field * * @var string * @validate NotEmpty */ protected $field1 = ''; /** * parent (should only hold one object) * * @var \Vendor\Extensionkey\Domain\Model\Testmodel */ protected $parent = NULL; ...getters and setters for field1 and $parent }
In an Extbase extension, I create a plugin which shows a form that should create a new object of type "Testmodel" on form submission.
Submitting an empty form results in the following:
TYPO3 6.2: The validator for $field1 is processed and the object is not created (createAction not processed)
TYPO3 Master: The validator for field1 is processes and the object gets created (createAction processed)
I created a little demo extension, which demonstrates the problem.
Link: https://github.com/derhansen/test_extension
In plugin "Form1", domain object validations works. For plugin "Form2" the domain object validation is ignored and empty forms can be submitted and gets saved.
It took me some hours of debugging to find out, that the @var \Vendor\Extensionkey\Domain\Model\Testmodel for $parent is the reason for this unexpected behaviour.
Changing the @var annotation to @var int or \TYPO3\CMS\Extbase\Persistence\ObjectStorage<\Vendor\Extensionkey\Domain\Model\Testmodel> for the $parent property seems to resolve the problem (getters and setters remain as they are).
Really strange problem, since empty forms can be saved to the database and the domain model validation is ignored completely.
Updated by Torben Hansen about 9 years ago
Debugged the problem down to this change (see my comments) https://review.typo3.org/#/c/40693/4
Updated by Stephan Großberndt about 9 years ago
- Target version set to 7.5
- Is Regression changed from No to Yes
- Sprint Focus set to Stabilization Sprint
Updated by Gerrit Code Review about 9 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 http://review.typo3.org/43564
Updated by Gerrit Code Review about 9 years ago
Patch set 2 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at http://review.typo3.org/43564
Updated by Stephan Großberndt about 9 years ago
- Status changed from Under Review to Resolved
- % Done changed from 0 to 100
Applied in changeset 4d2f978b9d53951a22911ee7924365aeedb63f96.
Updated by Riccardo De Contardi about 7 years ago
- Status changed from Resolved to Closed