[BUGFIX] Handle missing relations gracefully 58/38458/2
authorFrans Saris <franssaris@gmail.com>
Mon, 12 Jan 2015 20:26:23 +0000 (21:26 +0100)
committerMarkus Klein <klein.t3@reelworx.at>
Fri, 3 Apr 2015 13:01:39 +0000 (15:01 +0200)
Properly check if the referenced record is really existing,
when dealing with refindex and sys_file_reference in
ElementInformationController.

Releases: master, 6.2
Resolves: #65520
Change-Id: Iee89ef33ad8ccb96263207a8fc0a6a9a99ce9ed5
Reviewed-on: http://review.typo3.org/38458
Reviewed-by: Markus Klein <klein.t3@reelworx.at>
Tested-by: Markus Klein <klein.t3@reelworx.at>
typo3/sysext/backend/Classes/Controller/ContentElement/ElementInformationController.php
typo3/sysext/lang/locallang_core.xlf

index 65401ef..295e521 100644 (file)
@@ -541,6 +541,7 @@ class ElementInformationController {
 
                // Compile information for title tag:
                $infoData = array();
+               $infoDataHeader = '';
                if (count($rows)) {
                        $infoDataHeader = '<tr>' . '<td>&nbsp;</td>' . '<td>' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xlf:show_item.php.table') . '</td>' . '<td>' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xlf:show_item.php.title') . '</td>' . '<td>[uid]</td>' . '<td>' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xlf:show_item.php.field') . '</td>' . '<td>' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xlf:show_item.php.flexpointer') . '</td>' . '<td>' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xlf:show_item.php.softrefKey') . '</td>' . '<td>' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xlf:show_item.php.sorting') . '</td>' . '</tr>';
                }
@@ -552,19 +553,36 @@ class ElementInformationController {
                                }
                        }
                        $record = BackendUtility::getRecord($row['tablename'], $row['recuid']);
-                       $parentRecord = BackendUtility::getRecord('pages', $record['pid']);
-                       $actions = $this->getRecordActions($row['tablename'], $row['recuid']);
-                       $infoData[] = '<tr class="db_list_normal">' .
+                       if ($record) {
+                               $parentRecord = BackendUtility::getRecord('pages', $record['pid']);
+                               $parentRecordTitle = is_array($parentRecord)
+                                       ? BackendUtility::getRecordTitle('pages', $parentRecord)
+                                       : '';
+                               $actions = $this->getRecordActions($row['tablename'], $row['recuid']);
+                               $infoData[] = '<tr class="db_list_normal">' .
                                        '<td style="white-space:nowrap;">' . $actions . '</td>' .
                                        '<td>' . $GLOBALS['LANG']->sL($GLOBALS['TCA'][$row['tablename']]['ctrl']['title'], TRUE) . '</td>' .
                                        '<td>' . BackendUtility::getRecordTitle($row['tablename'], $record, TRUE) . '</td>' .
                                        '<td><span title="' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_common.xlf:page') . ': ' .
-                                                       htmlspecialchars(BackendUtility::getRecordTitle('pages', $parentRecord)) . ' (uid=' . $record['pid'] . ')">' .
+                                                       htmlspecialchars($parentRecordTitle) . ' (uid=' . $record['pid'] . ')">' .
                                                        $record['uid'] . '</span></td>' .
                                        '<td>' . htmlspecialchars($this->getLabelForTableColumn($row['tablename'], $row['field'])) . '</td>' .
-                                       '<td>' . htmlspecialchars($row['flexpointer']) . '</td>' . '<td>' . htmlspecialchars($row['softref_key']) . '</td>' .
+                                       '<td>' . htmlspecialchars($row['flexpointer']) . '</td>' .
+                                       '<td>' . htmlspecialchars($row['softref_key']) . '</td>' .
+                                       '<td>' . htmlspecialchars($row['sorting']) . '</td>' .
+                                       '</tr>';
+                       } else {
+                               $infoData[] = '<tr class="db_list_normal">' .
+                                       '<td style="white-space:nowrap;"></td>' .
+                                       '<td>' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xlf:show_item.php.missing_record') . ' (uid=' . $row['recuid'] . ')</td>' .
+                                       '<td>' . htmlspecialchars($GLOBALS['LANG']->sL($GLOBALS['TCA'][$row['tablename']]['ctrl']['title']) ?: $row['tablename']) . '</td>' .
+                                       '<td></td>' .
+                                       '<td>' . htmlspecialchars($this->getLabelForTableColumn($row['tablename'], $row['field'])) . '</td>' .
+                                       '<td>' . htmlspecialchars($row['flexpointer']) . '</td>' .
+                                       '<td>' . htmlspecialchars($row['softref_key']) . '</td>' .
                                        '<td>' . htmlspecialchars($row['sorting']) . '</td>' .
                                        '</tr>';
+                       }
                }
                $referenceLine = '';
                if (count($infoData)) {
@@ -652,4 +670,4 @@ class ElementInformationController {
                );
        }
 
-}
\ No newline at end of file
+}
index b5878aa..c5d482c 100644 (file)
@@ -433,6 +433,9 @@ Do you want to continue WITHOUT saving?</source>
                        <trans-unit id="show_item.php.ftp_area" xml:space="preserve">
                                <source>FTP AREA</source>
                        </trans-unit>
+                       <trans-unit id="show_item.php.missing_record">
+                               <source>Missing</source>
+                       </trans-unit>
                        <trans-unit id="db_new.php.pagetitle" xml:space="preserve">
                                <source>New record</source>
                        </trans-unit>