[TYPO3-dev] FAL raises exception with filterInlineChildren

Franz Holzinger franz.holzinger at ttproducts.de
Tue Sep 22 09:36:08 CEST 2015


Hello developers,

I have discovered a problem with the FAL, when I program a converter 
script which adds a relation between the extension table to the 
sys_file_reference.

The $TCA has been added to the table field.
	$GLOBALS['TCA'][tt_products_cat]['columns'][image_uid]



exclude	1
displayCond	EXT:filelist:LOADED:true
label	LLL:EXT:lang/locallang_general.php:LGL.image
config	
	type	inline
	foreign_table	sys_file_reference
	foreign_field	uid_foreign
	foreign_sortby	sorting_foreign
	foreign_table_field	tablenames
	foreign_match_fields	
	fieldname	image_uid
	foreign_label	uid_local
	foreign_selector	uid_local
	foreign_selector_fieldTcaOverride	
	config	
	appearance	
	elementBrowserType	file
	elementBrowserAllowed	
	filter	
		0	
			userFunc 
TYPO3\CMS\Core\Resource\Filter\FileExtensionFilter->filterInlineChildren
			parameters	
				allowedFileExtensions	
				disallowedFileExtensions	
	appearance	
		useSortable	1
		headerThumbnail	
			field	uid_local
			width	45
			height	45c
		showPossibleLocalizationRecords	
		showRemovedLocalizationRecords	
		showSynchronizationLink	
		showAllLocalizationLink	
		enabledControls	
			info	1
			new	
			dragdrop	1
			sort	
			hide	1
			delete	1
			localize	1
	behaviour	
		localizationMode	select
		localizeChildrenAtParentLocalization	1


The TCE insertion is done by this code:

$data = array();
$data['sys_file_reference']['NEW1234'] = array(
	'uid_local' => $fileUid,
	'uid_foreign' => $row['uid'], // uid of your table record
	'tablenames' => $tablename,
	'fieldname' => $imageFalFieldname,
	'pid' => $pid, // parent id of the parent page
	'table_local' => 'sys_file',
);
$data[$tablename][$row['uid']] = array($imageFalFieldname => 
$imageCount); // set to the number of images
debug ($data, 'INSERT $data');

/** @var \TYPO3\CMS\Core\DataHandling\DataHandler $tce */
$tce = 
\TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\CMS\Core\DataHandling\DataHandler'); 
// create TCE instance
$tce->start($data, array());
$tce->process_datamap();


I have calculated to count of related image file records into the 
variable $imageCount. Each record of the table tt_products_cat can have 
multiple images.

The data handler at first gets the record to insert within 
sys_file_reference:


DataHandler.php	1178	fillInFieldArray
DataHandler.php	1448	debug

Array
hidden	0
sorting_foreign	0
table_local	sys_file
showinpreview	0
sorting	1
pid	4
uid_local	646
uid_foreign	1
$fieldArray

This is processed fine.

However the record which is inserted into the table tt_products_cat fails.


DataHandler.php	1176	debug

Array
image_uid	1

process_datamap $incomingFieldArray


The TCE insertion process finally leads to a check:

TYPO3\CMS\Core\Resource\Filter\FileExtensionFilter->filterInlineChildren

This builds a wrong SQL.

SELECT * FROM sys_file_reference WHERE uid=1 AND 
sys_file_reference.deleted=0 LIMIT 1


uid = 1 should not be used at all, because 1 is the count of elements 
related between the record 1 of tt_products_cat to the table 
sys_file_reference. 1 is not an uid! It is wrongly used as the uid of 
the table sys_file_reference.

This will raise an exception.



Core: Exception handler (WEB): Uncaught TYPO3 Exception: #1317178794: No 
file usage (sys_file_reference) found for given UID. | 
TYPO3\\CMS\\Core\\Resource\\Exception\\ResourceDoesNotExistException 
thrown in file 
/var/www/html/typo3_src-6.2.15/typo3/sysext/core/Classes/Resource/ResourceFactory.php 
in line 572. Requested URL: 
http://localhost/typo3/mod.php?M=web_func&moduleToken=11fe087174c2574c4ae3a19a5f573b888526afd1




I have tried out to use another insertion record with a new element:


$data[$tablename][$row['uid']] = array($imageFalFieldname => 'NEW1234');


However this leads to a wrong UPDATE SQL:

UPDATE tt_products_cat SET image_uid='1' WHERE uid=1

Another image has already been assigned before. image_uid must be the 
image count which is 2 at this moment.



How should this issue be fixed?


Regard,

Franz






More information about the TYPO3-dev mailing list