Issue Bug Under Review Quiet

#111245Reverting from the oldest history entry of a workspace-versioned record marks it for deletion

Jure Milic 10/26/26, 08:30 updated 10/26/26, 09:17

Description

Summary

Reverting from the oldest history entry of a record that has been edited in a workspace marks the record for deletion, instead of just undoing the edit. Publishing the workspace then deletes it from the live site.

Environment

  • TYPO3 version: 14.3.10 (also present in 13.4 and 12.4 – the relevant code predates all of them)
  • Affected component: EXT:backend, TYPO3\CMS\Backend\History\RecordHistory / RecordHistoryRollback
  • No third-party extensions required to reproduce

Steps to reproduce

  1. Set up a page with EXT:workspaces active, and a draft workspace.
  2. In live, create a page with a content element on it.
  3. Switch the backend to the draft workspace.
  4. Edit the page’s title (or the content element’s header) and save. This is the record’s first save in the workspace – DataHandler silently creates a workspace version of it (versionizeRecord() -> copyRecord_raw() -> insertDB()), logged to sys_history as ACTION_ADD.
  5. Open the record’s History (Web > History, or the record’s “Last changes” panel).
  6. Two entries are shown: an “insert” (the version’s own silent creation) and a “change” (the title edit).
  7. Click the oldest entry (the “insert”) and revert from it (“Revert all” / revert the whole record).
  8. The page (and, for a page, any content nested under it) is now marked for deletion in the workspace (t3ver_state = 2, DELETE_PLACEHOLDER).
  9. Publishing the workspace (manually, or via the scheduled publish task) deletes the page/content from the live site.

Expected result

Reverting from that entry should only undo the title edit, restoring it to the value it had before this workspace touched the record. It must never delete the record.

Actual result

The record (and anything nested under it, for a page) is marked for deletion and removed on publish.

Root cause

DataHandler::insertDB() logs the creation of any new database row – including the workspace version it silently creates for an existing live record – as RecordHistoryStore::ACTION_ADD. RecordHistory::getDiff() treats every ACTION_ADD row as “this record was inserted,” with no way to distinguish a workspace version of an existing live record from a record genuinely created in the workspace. RecordHistoryRollback::performRollback() then turns that “insert” into a ['delete' => 1] DataHandler command.

The two cases are already distinguishable, though: insertDB()’s history_data payload for ACTION_ADD is the row’s own full field array, which includes t3ver_oid. A workspace version of an existing live record carries t3ver_oid = the live record’s uid (> 0); a record actually created in the workspace carries t3ver_oid = 0 (and t3ver_state = NEW_PLACEHOLDER). No extra DB lookup is needed – the already-logged row says which case it is.

Suggested fix

Filter these bookkeeping ACTION_ADD rows out in RecordHistory::getHistoryData(), since both the History module’s visible row list and getDiff() (which drives revert) consume its output. This hides the bookkeeping row from the History list and makes it un-revertible-as-a-delete, while a genuinely-new-in-workspace record (t3ver_oid = 0) still shows and reverts as a real insert. Patch attached.

Reviews 1

History 01