Issue Task New Quiet

#70020@transient properties should be ignored when checking if object is dirty

Philipp Wrann 09/22/15, 15:54 updated 10/18/26, 18:09

Description

I am currently working on a REST Api for TYPO3-7 and i recognized, that i allways get TRUE when checking AbstractEntity::_isDirty()

The problem is, that @transient properties are checked also.

But by using the ObjectAccess::getProperties and stuff a @transient property will be loaded via get-method, that way an objects internal logic may set the transient property as first-level-cache. I guess i am not the only one using that possibility.

Properties starting with an underscore (_languageUid) are ignored, @transient properties should also be ignored.

That could reduce database load a lot in certain contexts.

Reviews 1

History 4

  1. Georg Ringer commented <span data-processor="relativetime" data-value="2026-08-14T07:42:46+00:00" > 08/14/26, 07:42 </span>

    Still accurate on current main, but the stated reasoning no longer holds. Details below, so
    that whoever picks this up does not chase the wrong benefit.

    The mechanism is unchanged

    transient is a PHP attribute these days, #[Transient] from
    @TYPO3\CMS\Extbase\Attribute\ORM@, and ClassSchema\Property::isTransient() exists. The
    described behaviour is still there:

    • AbstractDomainObject::_getProperties() uses get_object_vars($this) and filters
      only properties prefixed with an underscore. Transient properties stay in.
    • DataMapper::mapSingleRow() calls $object->_memorizeCleanState() without an argument,
      so everything that survived the above lands in _cleanProperties.
    • _isDirty() without an argument iterates exactly that list, so transient properties are
      compared.

    But it does not cause database load

    The expectation “that could reduce database load a lot” does not apply to current core.
    @Backend::persistObject()@ iterates $classSchema->getDomainObjectProperties() and skips
    every property for which !$dataMap->isPersistableProperty($propertyName) holds – and
    @isPersistableProperty()@ is just isset($this->columnMaps[$propertyName]). A transient
    property has no column, so it has no column map, so it never gets that far.

    On top of that, persisting uses the property specific $object->_isDirty($propertyName)
    throughout, never the argument-less variant. $row can therefore not receive anything from
    a transient property, and the write is guarded by if (!empty($row)).

    A dirty transient property triggers no UPDATE. No query, no bumped tstamp.

    What the actual impact is

    1. Third party code calling _isDirty() itself – the REST API case from the report. Neither
      _isDirty() nor ObjectMonitoringInterface carry an internal@ annotation, so this is
      legitimate public API returning a wrong answer. Core itself has no such call: the only
      argument-less usages are in Backend (on an ObjectStorage, which has its own
      implementation) and in DebuggerUtility.
    2. DebuggerUtility renders the object as “modified”. Cosmetic, and mildly ironic, since the
      same method labels those properties as transient a few lines further down.
    3. The argument the report does not make, and the stronger one: _memorizePropertyCleanState()
      clones every object valued property. The use case in the report is a transient property
      used as a first level cache, so that object is cloned on every single reconstitution
      through the DataMapper. That costs memory and invokes __clone on objects never designed
      for it – and it happens whether or not anybody ever calls _isDirty().

    Where a fix belongs

    Not in AbstractDomainObject. It is a plain object without dependency injection and would
    need a global lookup to reach the ClassSchema, and changing _getProperties() or
    @_memorizeCleanState()@ alters the contract of public API.

    The clean seam is the call site, DataMapper::mapSingleRow(). The DataMapper already has
    @ReflectionService@ injected and fetches the ClassSchema in several places. Instead of the
    argument-less _memorizeCleanState() it could iterate the non-transient properties and call
    @_memorizePropertyCleanState($propertyName)@ for each. Anyone calling _memorizeCleanState()
    themselves keeps the current behaviour.

    To verify while doing so: whether anything relies on _getCleanProperty() returning
    something for a transient property. The only core call is in Backend and concerns
    @ObjectStorage@ properties, which are persistable.

    Suggested housekeeping

    The description should be rewritten to what actually applies – a public API returning a wrong
    answer, plus needless cloning on every reconstitution – otherwise the next person evaluates
    this against a database load benefit that is not there. Target version is still “7 LTS”.
    This is a [TASK] for main with functional tests; it touches persistence, so not an easy one.

  2. Alexander Schnitzler commented <span data-processor="relativetime" data-value="2026-10-18T18:09:46+00:00" > 10/18/26, 18:09 </span>

    My plan here is to drop the Transient attribute altogether and rely on the TCA to decide whether a property should be mapped and tracked for
    changes. This is part of a rather big epic, so I would not spend time on reintroducing the evaluation of that attribute. We do not need it technically, and it did not have much of an impact over the years.