[BUGFIX] Show links to missing records in InputLink 89/55789/2
authorAlexander Opitz <opitz.alexander@googlemail.com>
Fri, 16 Feb 2018 10:10:21 +0000 (11:10 +0100)
committerAndreas Wolf <andreas.wolf@typo3.org>
Sun, 18 Feb 2018 12:44:30 +0000 (13:44 +0100)
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
(cherry picked from commit aa4ce89d5263d5258ae8e35dc5daeb9eb9fae561)
Reviewed-on: https://review.typo3.org/55789
Reviewed-by: Andreas Wolf <andreas.wolf@typo3.org>
Tested-by: Andreas Wolf <andreas.wolf@typo3.org>
typo3/sysext/backend/Classes/Form/Element/InputLinkElement.php

index 384db8c..7fdcecb 100644 (file)
@@ -398,12 +398,23 @@ class InputLinkElement extends AbstractFormElement
             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