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 #1

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

Actions #2

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
Actions #3

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

Actions #4

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

Actions #5

Updated by Stephan Großberndt about 9 years ago

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

Updated by Riccardo De Contardi about 7 years ago

  • Status changed from Resolved to Closed
Actions

Also available in: Atom PDF