Project

General

Profile

Actions

Bug #70017

closed

Domain object validation ignored, when object has property of the same type

Added by Torben Hansen about 9 years ago. Updated about 7 years ago.

Status:
Closed
Priority:
Must have
Assignee:
-
Category:
-
Target version:
Start date:
2015-09-22
Due date:
% Done:

100%

Estimated time:
TYPO3 Version:
7
PHP Version:
5.6
Tags:
Complexity:
Is Regression:
Yes
Sprint Focus:
Stabilization Sprint

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.


Related issues 1 (0 open1 closed)

Follows TYPO3 Core - Task #67786: Replace count with empty in EXT:extbaseClosed2015-06-27

Actions
Actions

Also available in: Atom PDF