Issue Task Resolved

#110585Record history rollback treats moved records as deleted

Benni Mack 09/01/26, 19:25 updated 09/01/26, 21:05

Description

\TYPO3\CMS\Backend\History\RecordHistory::getDiff() builds the insertsDeletes map that drives the rollback preview and RecordHistoryRollback::performRollback(). It branches on every action type that is not ACTION_MODIFY, then increments when the entry carries
@action = ‘insert’@ and decrements otherwise.

prepareEventDataFromQueryBuilder() only sets action for ACTION_ADD and ACTION_UNDELETE (“insert”), ACTION_DELETE (“delete”) and ACTION_PUBLISH (“publish”). So ACTION_MOVE and ACTION_STAGECHANGE carry no action at all, and ACTION_PUBLISH carries a value that is not insert — all three decrement and are therefore counted as deletions.

Reproduced against the class:

changelog: [MOVE, MODIFY]         => insertsDeletes: ['tt_content:5' => -1]
changelog: [PUBLISH, STAGECHANGE] => insertsDeletes: ['tt_content:5' => -2]

Effects:

  • A record that was only moved renders the preview text “The record has been deleted and will be restored again with the rollback”, and performRollback() issues an undelete command for a record that was never deleted.
  • Two such entries sum to -2, which is handled neither by the preview (=== -1) nor by performRollback() (=== 1 / === -1). The entry is silently dropped, so a real delete next to a move can become unrecoverable through the UI.
  • Inside a workspace, where ACTION_STAGECHANGE entries are visible, nearly every rollback preview is skewed.

Expected: only ACTION_ADD and ACTION_UNDELETE count as an insert, only ACTION_DELETE as a delete. Move, stage change and publish must not enter
@insertsDeletes@ at all.

There is currently no functional test for getDiff() or performRollback(); the fix should add one covering all seven action types.

Reviews 3

History 14

  1. Benni Mack commented and changed status Under Review Resolved done 0 % 100 % <span data-processor="relativetime" data-value="2026-09-01T21:05:08+00:00" > 09/01/26, 21:05 </span>

    Applied in changeset commit:e260a60375aab40e249a0417c26264e9e90bd8b5.