Breaking: #95823 - Property access methods of AbstractDomainObject removed 

See forge#95823

Description 

The following internal methods have been removed from \TYPO3\CMS\Extbase\DomainObject\AbstractDomainObject and \TYPO3\CMS\Extbase\DomainObject\DomainObjectInterface :

  • _setProperty()
  • _getProperty()
  • _hasProperty()

Extbase no longer reads and writes entity properties from inside the entity. The persistence layer accesses the entity from outside via reflection, using the methods getRawEntityPropertyValue() , setRawEntityPropertyValue() and hasEntityProperty() of \TYPO3\CMS\Extbase\Reflection\ReflectionService .

These methods work on the raw property values: property hooks, getters and setters of the entity are not called. Private properties declared in the model class itself are read, written and persisted as well, which was not the case with the removed methods. Private properties of a parent class are not entity properties. Virtual properties (property hooks without a backing value) hold no state and are ignored.

The Extbase UriBuilder and the ViewHelper <f:render.text> read the properties of Extbase domain objects the same way: link arguments built from a value object and the rendered field of an Extbase model use the raw property value. Virtual properties are neither added as link arguments nor found as fields.

Impact 

Calling one of the removed methods results in a fatal PHP error.

Property hooks of Extbase models are no longer executed while the persistence layer reconstitutes or persists an entity.

Property hooks are not executed either when the UriBuilder turns a value object into link arguments or when <f:render.text> renders a field of an Extbase model.

Custom implementations of the removed methods in a model are no longer called by Extbase.

Affected installations 

Installations with extensions that call _setProperty() , _getProperty() or _hasProperty() on Extbase domain objects, for example to set the uid of an entity in tests, or that override these methods in a model.

Installations with Extbase models that rely on property hooks being executed when records are loaded or persisted, when value objects are used as link arguments or when models are rendered with <f:render.text> .

The extension scanner reports calls of the removed methods as weak matches, as it only matches the method names and cannot tell which class a method is called on. Models that override one of the removed methods are not reported.

Migration 

Read and write the property with PHP reflection. This works with TYPO3 v14 and v15:

// Before: $entity->_setProperty('uid', 42);
(new \ReflectionProperty($entity, 'uid'))->setValue($entity, 42);

// Before: $entity->_getProperty('title');
$property = new \ReflectionProperty($entity, 'title');
$title = $property->isInitialized($entity)
    ? $property->getValue($entity)
    : null;

// Before: $entity->_hasProperty('title');
$hasTitle = property_exists($entity, 'title');
Copied!

Logic that has to run after an entity has been reconstituted belongs into initializeObject() of the model or an event listener for \TYPO3\CMS\Extbase\Event\Persistence\AfterObjectThawedEvent .