Issue Bug Under Review

#111620Saving a record without changes logs a history entry for every group field with an MM table and a single allowed table

Sebastian Michaelsen 11/26/26, 12:57 updated 11/26/26, 13:33

Description

Problem

When a record is saved through FormEngine without any change, DataHandler writes a sys_history entry for each type=group field that has an MM table and exactly one table in allowed, as long as the field has relations. The record and the MM rows stay unchanged. The entry repeats on every save, so the record history fills up with changes that never happened.

The entry looks like this (here for the related field of EXT:news):

{"oldRecord":{"related":"2,3"},"newRecord":{"related":"tx_news_domain_model_news_2,tx_news_domain_model_news_3"}}

Steps to reproduce

Configure a group field with an MM table and a single allowed table, for example:

'related_items' => [
    'config' => [
        'type' => 'group',
        'allowed' => 'tx_example_item',
        'MM' => 'tx_example_item_related_mm',
    ],
],

The related field of tx_news_domain_model_news in EXT:news has this configuration and works as a ready-made example.

  1. Add two relations to a record and save it.
  2. Open the record and save it again without changing anything.
  3. Check sys_history for the record.

Expected: the unchanged save writes no history entry.

Actual: every unchanged save writes a “modify” entry for the field, with the old relations as plain uids and the new relations with table name prefixes.

Reproduced with a functional test on 14.3.12. Saving through DataHandler with the value FormEngine submits (tx_news_domain_model_news_2,tx_news_domain_model_news_3) writes the entry on every save. Saving with plain uids (2,3) writes none. The MM rows are the same in both cases.

Cause

DataHandler::checkValue_group_select_processDBdata() compares two lists in different formats:

$newRelations = implode(',', $valueArray);
...
$oldRelations_dbAnalysis->initializeForField($currentTable, $tcaFieldConf, $id);
$oldRelations = implode(',', $oldRelations_dbAnalysis->getValueArray());
$dbAnalysis->writeMM($tcaFieldConf['MM'], $id, $prep);
if ($oldRelations != $newRelations) {
    $this->mmHistoryRecords[$currentTable . ':' . $id]['oldRecord'][$currentField] = $oldRelations;
    $this->mmHistoryRecords[$currentTable . ':' . $id]['newRecord'][$currentField] = $newRelations;
  • $newRelations is the submitted value. FormEngine always submits group values as <table>_<uid>.
  • $oldRelations comes from RelationHandler::getValueArray(), which prefixes table names only when more than one table is involved. With a single allowed table it returns plain uids.

The two strings never match for a single-table group field, so every save counts as a change. Select fields and Group fields are not affected.

Proposed fix

Compare the normalised value arrays of both relation handlers instead of the raw submitted string. In other words, build the new list from $dbAnalysis->getValueArray() the same way the old list is built, and log that list in the history entry as well.

Reviews 1

History 02

  1. Gerrit Code Review pushed patch set 1 for main to change 98066 status New Under Review 11/26/26, 13:27

  2. Gerrit Code Review pushed patch set 2 for main to change 98066 11/26/26, 13:33