[BUGFIX] Handle missing relations gracefully 78/35978/9
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 12:48:50 +0000 (14:48 +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/35978
Reviewed-by: Frans Saris <franssaris@gmail.com>
Tested-by: Frans Saris <franssaris@gmail.com>
Reviewed-by: Wouter Wolters <typo3@wouterwolters.nl>
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 451ea40..0a04b14 100644 (file)
@@ -613,6 +613,7 @@ class ElementInformationController {
 
                // Compile information for title tag:
                $infoData = array();
 
                // Compile information for title tag:
                $infoData = array();
+               $infoDataHeader = '';
                if (count($rows)) {
                        $infoDataHeader = '
                                <tr>
                if (count($rows)) {
                        $infoDataHeader = '
                                <tr>
@@ -635,11 +636,15 @@ class ElementInformationController {
                                }
                        }
                        $record = BackendUtility::getRecord($row['tablename'], $row['recuid']);
                                }
                        }
                        $record = BackendUtility::getRecord($row['tablename'], $row['recuid']);
-                       $parentRecord = BackendUtility::getRecord('pages', $record['pid']);
-                       $icon = (is_array($record)) ? IconUtility::getSpriteIconForRecord($row['tablename'], $record) : '';
-                       $actions = $this->getRecordActions($row['tablename'], $row['recuid']);
-                       $editOnClick = BackendUtility::editOnClick('&edit[' . $row['tablename'] . '][' . $row['recuid'] . ']=edit');
-                       $infoData[] = '
+                       if ($record) {
+                               $parentRecord = BackendUtility::getRecord('pages', $record['pid']);
+                               $parentRecordTitle = is_array($parentRecord)
+                                       ? BackendUtility::getRecordTitle('pages', $parentRecord)
+                                       : '';
+                               $icon = IconUtility::getSpriteIconForRecord($row['tablename'], $record);
+                               $actions = $this->getRecordActions($row['tablename'], $row['recuid']);
+                               $editOnClick = BackendUtility::editOnClick('&edit[' . $row['tablename'] . '][' . $row['recuid'] . ']=edit');
+                               $infoData[] = '
                                <tr>
                                        <td class="col-icon">
                                                <a href="#" onclick="' . htmlspecialchars($editOnClick) . '" title="id=' . $record['uid'] . '">
                                <tr>
                                        <td class="col-icon">
                                                <a href="#" onclick="' . htmlspecialchars($editOnClick) . '" title="id=' . $record['uid'] . '">
@@ -653,8 +658,8 @@ class ElementInformationController {
                                        </td>
                                        <td>' . $GLOBALS['LANG']->sL($GLOBALS['TCA'][$row['tablename']]['ctrl']['title'], TRUE) . '</td>
                                        <td>
                                        </td>
                                        <td>' . $GLOBALS['LANG']->sL($GLOBALS['TCA'][$row['tablename']]['ctrl']['title'], TRUE) . '</td>
                                        <td>
-                                               <span title="' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_common.xlf:page') . ': ' .
-                                                       htmlspecialchars(BackendUtility::getRecordTitle('pages', $parentRecord)) . ' (uid=' . $record['pid'] . ')">
+                                               <span title="' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_common.xlf:page') . ': '
+                                                       . htmlspecialchars($parentRecordTitle) . ' (uid=' . $record['pid'] . ')">
                                                        ' . $record['uid'] . '
                                                </span>
                                        </td>
                                                        ' . $record['uid'] . '
                                                </span>
                                        </td>
@@ -664,6 +669,20 @@ class ElementInformationController {
                                        <td>' . htmlspecialchars($row['sorting']) . '</td>
                                        <td class="col-control">' . $actions . '</td>
                                </tr>';
                                        <td>' . htmlspecialchars($row['sorting']) . '</td>
                                        <td class="col-control">' . $actions . '</td>
                                </tr>';
+                       } else {
+                               $infoData[] = '
+                               <tr>
+                                       <td class="col-icon"></td>
+                                       <td class="col-title">' . $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>
+                                       <td class="col-control"></td>
+                               </tr>';
+                       }
                }
                $referenceLine = '';
                if (count($infoData)) {
                }
                $referenceLine = '';
                if (count($infoData)) {
index 44d1261..ab2e900 100644 (file)
@@ -463,6 +463,9 @@ Do you want to continue WITHOUT saving?</source>
                        <trans-unit id="show_item.php.ftp_area">
                                <source>FTP AREA</source>
                        </trans-unit>
                        <trans-unit id="show_item.php.ftp_area">
                                <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">
                                <source>New record</source>
                        </trans-unit>
                        <trans-unit id="db_new.php.pagetitle">
                                <source>New record</source>
                        </trans-unit>