Project

General

Profile

Actions

Bug #62056

closed

Extbase disregards discriminator when retrieving existing Value Object UIDs

Added by Philipp Maier about 10 years ago. Updated over 6 years ago.

Status:
Closed
Priority:
Must have
Assignee:
-
Category:
Extbase
Target version:
-
Start date:
2014-10-06
Due date:
% Done:

0%

Estimated time:
TYPO3 Version:
6.2
PHP Version:
Tags:
Complexity:
medium
Is Regression:
No
Sprint Focus:

Description

When using STI with Value Objects only the actual properties of the Value Object are checked and searched for in the database in order to find any existing UID. The TCA type column which defines the object type is disregarded at this point. The result is a wrong relation and wrong object type.

Consider following example:

Parent extends AbstractValueObject {
  protected $someValue = '';
}
Child1 extends Parent {}
Child2 extends Parent {}

SomeObject {
  // many to one relation to Parent
  /** @var Parent */
  protected $object;
}

Given the TCA configuration is correct and you have already a Child1 persisted with the default value, the following code will fail:
$someObject->setObject(new Child2());

After fetching $someObject from the database again, it will contain an instance of Child1, and not Child2.

As a workaround, the Value Object can be extended with a property containing the FQCN. In this case it would work as expected.

Actions

Also available in: Atom PDF