#111342Record history of a deleted record fails: "Trying to access array offset on null" in RecordHistory::getTranslations()
Description
Since 14.2.0 the record history shows a language switcher (ElementHistoryController::addLanguageSwitcher()). It calls RecordHistory::getTranslations(), which reads the record and its translation origin with BackendUtility::getRecord() including the deleted restriction. For a deleted record both lookups return null, and the array access on $translationRoot fails:
- any table other than pages: RecordHistory.php line 188 (14.3.10), (int)$translationRoot[‘pid’]
- pages: line 192, (int)$translationRoot[$langField]
The same applies to a translation whose default language record is deleted.
With E_WARNING in SYS/exceptionalErrors (e.g. the Debug preset, 12290) the history view ends with HTTP 500:
#1476107295 TYPO3\CMS\Core\Error\Exception PHP Warning: Trying to access array offset on null in .../typo3/cms-backend/Classes/History/RecordHistory.php line 188
The rest of the history view deliberately supports deleted records (e.g. ElementHistoryController::setPagePath() reads them with $useDeleteClause = false), and the history of a deleted record is exactly where an editor rolls back the deletion. TYPO3 14.1 and earlier are not affected.
Steps to reproduce
- Create a content element on a page and delete it.
- Open the history of the page (context menu of the page → History).
- In the changelog row of the deleted content element, click the filter icon (“Show history for this record”), or call /typo3/record/history?element=tt_content:<uid> directly.</uid>
- Result: exception #1476107295 (line 188).
- Same with a deleted page: element=pages:<uid> fails in line 192.</uid>
Expected result
The history of the deleted record is shown, including the rollback of the deletion, as in 14.1. Without a translation root there is nothing to switch between, so the language switcher can be omitted.
Possible fix
Return null from getTranslations() when the translation root cannot be read (patch against main):
--- a/typo3/sysext/backend/Classes/History/RecordHistory.php
+++ b/typo3/sysext/backend/Classes/History/RecordHistory.php
@@ -169,6 +169,10 @@
$translationRoot = $record;
} else {
$translationRoot = BackendUtility::getRecord($table, $defaultLanguageUid);
+ }
+ if ($translationRoot === null) {
+ // The record or its translation origin is deleted, there is nothing to switch between
+ return null;
}
$queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)
Alternatively, read the record and the translation root without the deleted restriction, so deleted records keep the switcher.
Environment
TYPO3 14.3.10 (Composer), the code is unchanged on the 14.3 and main branches; PHP 8.4.20. We currently work around it with an XCLASS of RecordHistory that applies the check above.
Reviews 1
History 12
-
Maike Kiebele changed assigned to Maike Kiebele <span data-processor="relativetime" data-value="2026-11-09T13:45:37+00:00" > 11/09/26, 13:45 </span>
-
Gerrit Code Review pushed patch set 1 for main to change 97570 status
NewUnder Review <span data-processor="relativetime" data-value="2026-11-12T08:13:34+00:00" > 11/12/26, 08:13 </span>