Skip to content

Commit

Permalink
[BUGFIX] Show links to missing records in InputLink
Browse files Browse the repository at this point in the history
If the linked record wasn't found (wrong uid, removed from database) we
check before trying to gather an icon for the non-existing record.

Resolves: #81804
Releases: master, 8.7
Change-Id: Ie06ec8a614650d8147f143cda8d8e6a9cb3e98e9
Reviewed-on: https://review.typo3.org/55751
Reviewed-by: Andreas Wolf <andreas.wolf@typo3.org>
Tested-by: Andreas Wolf <andreas.wolf@typo3.org>
  • Loading branch information
opi99 authored and andreaswolf committed Feb 18, 2018
1 parent 498f411 commit aa4ce89
Showing 1 changed file with 17 additions and 6 deletions.
23 changes: 17 additions & 6 deletions typo3/sysext/backend/Classes/Form/Element/InputLinkElement.php
Original file line number Diff line number Diff line change
Expand Up @@ -394,12 +394,23 @@ protected function getLinkExplanation(string $itemValue): array
case LinkService::TYPE_RECORD:
$table = $this->data['pageTsConfig']['TCEMAIN.']['linkHandler.'][$linkData['identifier'] . '.']['configuration.']['table'];
$record = BackendUtility::getRecord($table, $linkData['uid']);
$recordTitle = BackendUtility::getRecordTitle($table, $record);
$tableTitle = $this->getLanguageService()->sL($GLOBALS['TCA'][$table]['ctrl']['title']);
$data = [
'text' => sprintf('%s [%s:%d]', $recordTitle, $tableTitle, $linkData['uid']),
'icon' => $this->iconFactory->getIconForRecord($table, $record, Icon::SIZE_SMALL)->render()
];
if ($record) {
$recordTitle = BackendUtility::getRecordTitle($table, $record);
$tableTitle = $this->getLanguageService()->sL($GLOBALS['TCA'][$table]['ctrl']['title']);
$data = [
'text' => sprintf('%s [%s:%d]', $recordTitle, $tableTitle, $linkData['uid']),
'icon' => $this->iconFactory->getIconForRecord($table, $record, Icon::SIZE_SMALL)->render(),
];
} else {
$icon = $GLOBALS['TCA'][$table]['ctrl']['typeicon_classes']['default'];
if (empty($icon)) {
$icon = 'tcarecords-' . $table . '-default';
}
$data = [
'text' => sprintf('%s', $linkData['uid']),
'icon' => $this->iconFactory->getIcon('tcarecords-' . $table . '-default', Icon::SIZE_SMALL, 'overlay-missing')->render(),
];
}
break;
default:
// Please note that this hook is preliminary and might change, as this element could become its own
Expand Down

0 comments on commit aa4ce89

Please sign in to comment.