[BUGFIX] Show links to missing records in InputLink 51/55751/4
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:12:26 +0000 (13:12 +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
Reviewed-on: https://review.typo3.org/55751
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 db2c12d..0c133df 100644 (file)
@@ -394,12 +394,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