From ad18a7531813113c01bd1546395cb56f2b570dc7 Mon Sep 17 00:00:00 2001
From: Francois Suter <francois@typo3.org>
Date: Sat, 5 Nov 2011 09:23:27 +0100
Subject: [PATCH] [BUGFIX] Fatal error when exporting from root

An uncaught exception happens when trying to export records from a
singe table view in List mode on the page tree root. This is due to
the tree root being handled as a normal page record.

With this patch the tree root is handled as it should. Some cleanup
(CGL) is also applied.

Change-Id: Ia5c46044f5040472846f3e7fb4adbf203e5e1e6a
Fixes: #31350
Releases: 4.7, 4.6, 4.5
Reviewed-on: http://review.typo3.org/6551
Reviewed-by: Philipp Gampe
Tested-by: Philipp Gampe
Reviewed-by: Georg Ringer
Reviewed-by: Steffen Ritter
Reviewed-by: Francois Suter
Tested-by: Francois Suter
---
 typo3/sysext/impexp/app/index.php | 25 ++++++++++++++++---------
 1 file changed, 16 insertions(+), 9 deletions(-)

diff --git a/typo3/sysext/impexp/app/index.php b/typo3/sysext/impexp/app/index.php
index ec28ab90693d..e275f5d00e1e 100755
--- a/typo3/sysext/impexp/app/index.php
+++ b/typo3/sysext/impexp/app/index.php
@@ -813,16 +813,23 @@ class SC_mod_tools_log_index extends t3lib_SCbase {
 					<td colspan="2">'.$LANG->getLL('makeconfig_exportTablesFromPages',1).'</td>
 				</tr>';
 
+				// Display information about pages from which the export takes place
 			$tblList = '';
-			foreach($inData['list'] as $ref)	{
-				$rParts = explode(':', $ref);
-				$tName = $rParts[0];
-
-				if ($GLOBALS['BE_USER']->check('tables_select',$tName))	{
-					$rec = t3lib_BEfunc::getRecordWSOL('pages', $rParts[1]);
-					$tblList .= 'Table "' . $tName . '" from ' . t3lib_iconworks::getSpriteIconForRecord('pages', $rec) .
-					t3lib_BEfunc::getRecordTitle('pages', $rec, TRUE).
-					'<input type="hidden" name="tx_impexp[list][]" value="'.htmlspecialchars($ref).'" /><br/>';
+			foreach ($inData['list'] as $reference) {
+				$referenceParts = explode(':', $reference);
+				$tableName = $referenceParts[0];
+
+				if ($GLOBALS['BE_USER']->check('tables_select', $tableName)) {
+						// If the page is actually the root, handle it differently
+						// NOTE: we don't compare integers, because the number actually comes from the split string above
+					if ($referenceParts[1] === '0') {
+						$iconAndTitle = t3lib_iconWorks::getSpriteIcon('apps-pagetree-root') . $GLOBALS['TYPO3_CONF_VARS']['SYS']['sitename'];
+					} else {
+						$record = t3lib_BEfunc::getRecordWSOL('pages', $referenceParts[1]);
+						$iconAndTitle = t3lib_iconworks::getSpriteIconForRecord('pages', $record) . t3lib_BEfunc::getRecordTitle('pages', $record, TRUE);
+					}
+					$tblList .= 'Table "' . $tableName . '" from ' . $iconAndTitle .
+					'<input type="hidden" name="tx_impexp[list][]" value="' . htmlspecialchars($reference) . '" /><br/>';
 				}
 			}
 			$row[] = '
-- 
GitLab