Issue Bug Closed

#75271TYPO3\CMS\Core\Imaging\IconFactory::getIconForRecord() throws an exception in some cases

Petra Arentzen 03/25/16, 18:48 updated 05/14/16, 19:49

Description

TYPO3\CMS\Core\Imaging\IconFactory::getIconForRecord() throws an exception about wrong parameter-type for second argument which is NULL but should be an array, if ‘internal_type’ is ‘DB’ and “prepend_tname” is set to false in TCA-FieldConf
In that case a fallback is done:
src/typo3_src/typo3/sysext/backend/Classes/Form/Element/GroupElement.php:276 – 291

                foreach ($temp_itemArray as $dbRead) {
                    $recordParts = explode('|', $dbRead);
                    list($this_table, $this_uid) = BackendUtility::splitTable_Uid($recordParts[0]);
                    // For the case that no table was found and only a single table is defined to be allowed, use that one:
                    if (!$this_table && $onlySingleTableAllowed) {
                        $this_table = $allowed;
                    }
                    $itemArray[] = array('table' => $this_table, 'id' => $this_uid);
                    if (!$disabled && $show_thumbs) {
                        $rr = BackendUtility::getRecordWSOL($this_table, $this_uid);
                        $thumbnails[] = array(
                            'name' => BackendUtility::getRecordTitle($this_table, $rr, true),
                            'image' => $this->iconFactory->getIconForRecord($this_table, $rr, Icon::SIZE_SMALL)->render(),
                            'path' => BackendUtility::getRecordPath($rr['pid'], $perms_clause, 15),
                            'uid' => $rr['uid'],
                            'table' => $this_table
                        );
                    }
                }

I think this must be changed:

                    if (!$this_table && $onlySingleTableAllowed) {
                        $this_table = $allowed;
                    }
                    if (!$this_table && $onlySingleTableAllowed) {
                        $this_table = reset($allowed);
                    }

Otherwise $rr is set to NULL and the Exception is thrown.
Also perhaps always the case where record is not found should be handled?

Reviews 0

No change resolves or names this issue in its commit message, and no comment links one.