Commit 451b4903 authored by Petra Arentzen's avatar Petra Arentzen Committed by Markus Klein
Browse files

[BUGFIX] Throw empty table name exception in TCE GroupElement

Throw an exception if table name is empty after parsing the value
by BackendUtility::splitTable_Uid(). It avoids calling
IconFactory::getIconForRecord() with the invalid parameter $row
and throwing a less specific exception then. Only fields with
TCA Configuration type='group', internal_type='db' and
show_thumbs=TRUE are concerned.

Resolves: #76232
Releases: master, 7.6
Change-Id: I44c52f6ebfdbcfbbd2209890b0458b8126cbeccd
Reviewed-on: https://review.typo3.org/48765

Tested-by: default avatarBamboo TYPO3com <info@typo3.com>
Reviewed-by: Christian Kuhn's avatarChristian Kuhn <lolli@schwarzbu.ch>
Tested-by: Christian Kuhn's avatarChristian Kuhn <lolli@schwarzbu.ch>
Reviewed-by: default avatarJoerg Boesche <typo3@joergboesche.de>
Tested-by: default avatarJoerg Boesche <typo3@joergboesche.de>
Reviewed-by: Markus Klein's avatarMarkus Klein <markus.klein@typo3.org>
Tested-by: Markus Klein's avatarMarkus Klein <markus.klein@typo3.org>
Reviewed-by: Wouter Wolters's avatarWouter Wolters <typo3@wouterwolters.nl>
parent d7f338b6
......@@ -34,6 +34,7 @@ class GroupElement extends AbstractFormElement
* the file system or database can be inserted. Relations.
*
* @return array As defined in initializeResultArray() of AbstractNode
* @throws \RuntimeException
*/
public function render()
{
......@@ -273,8 +274,17 @@ class GroupElement extends AbstractFormElement
foreach ($temp_itemArray as $dbRead) {
$recordParts = explode('|', $dbRead);
list($this_table, $this_uid) = BackendUtility::splitTable_Uid($recordParts[0]);
$itemArray[] = array('table' => $this_table, 'id' => $this_uid);
if (!$disabled && $show_thumbs) {
if (empty($this_table)) {
throw new \RuntimeException(
'Table name could not been determined for field "' . $fieldName . '" in table "' . $table . '". ' .
'This should never happen since the table name should have been already prepared in the DataProvider TcaGroup. ' .
'Maybe the prepared values have been set to an invalid value by a user defined data provider.',
1468149217
);
}
$rr = BackendUtility::getRecordWSOL($this_table, $this_uid);
$thumbnails[] = array(
'name' => BackendUtility::getRecordTitle($this_table, $rr, true),
......
<?php
namespace TYPO3\CMS\Backend\Tests\Unit\Form;
/*
* This file is part of the TYPO3 CMS project.
*
* It is free software; you can redistribute it and/or modify it under
* the terms of the GNU General Public License, either version 2
* of the License, or any later version.
*
* For the full copyright and license information, please read the
* LICENSE.txt file that was distributed with this source code.
*
* The TYPO3 project - inspiring people to share!
*/
use Prophecy\Argument;
use TYPO3\CMS\Backend\Form\Element\GroupElement;
use TYPO3\CMS\Backend\Form\NodeFactory;
use TYPO3\CMS\Core\Authentication\BackendUserAuthentication;
use TYPO3\CMS\Core\Tests\UnitTestCase;
use TYPO3\CMS\Lang\LanguageService;
/**
* Test case
*/
class GroupElementTest extends UnitTestCase
{
/**
* @test
*/
public function renderThrowsExceptionIfDbRecordsDoNotContainTableName()
{
$data = [
'parameterArray' => [
'fieldConf' => [
'config' => [
'allowed' => 'aForeignTable',
'internal_type' => 'db',
'show_thumbs' => true,
],
],
// This should trigger the exception, a correct value would be 'aForeignTable_42|aLabel'
'itemFormElValue' => 42
],
];
$languageService = $this->prophesize(LanguageService::class);
$GLOBALS['LANG'] = $languageService->reveal();
$languageService->sL(Argument::cetera())->willReturnArgument(0);
$backendUserAuthentication = $this->prophesize(BackendUserAuthentication::class);
$GLOBALS['BE_USER'] = $backendUserAuthentication->reveal();
$backendUserAuthentication->getPagePermsClause(1)->willReturn(1);
$nodeFactoryProphecy = $this->prophesize(NodeFactory::class);
$subject = new GroupElement($nodeFactoryProphecy->reveal(), $data);
$this->expectException(\RuntimeException::class);
$this->expectExceptionCode(1468149217);
$subject->render();
}
}
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment