Issue Bug Closed

#64239Catchable fatal error in PageRepository::getFileReferences() if no reference exists

Jacob Rasmussen 01/11/15, 14:54 updated 10/23/17, 21:48

Description

Due to a missing check on the type of $element in TYPO3\CMS\Frontend\ContentObject\FilesContentObject->handleFileReferences(), it is possible to crash page rendering.

By using a configuration like below

10 = FILES
10 {
    references {
        table = tx_someforeign_table
        uid.field = identifier_field
        fieldName = reference_field_name
    }
    renderObj = IMAGE
    renderObj.file {
        import.data = file:current:uid
        treatIdAsReference = 1
    }
}

And having a NULL / empty value in the identifier_field, a fatal error is triggered.

PHP Catchable fatal error: Argument 3 passed to TYPO3\\CMS\\Frontend\\Page\\PageRepository::getFileReferences() must be of the type array, null given, called in /var/www/typo3_src/TYPO3_6-2/typo3/sysext/frontend/Classes/ContentObject/FilesContentObject.php on line 317 and defined in /var/www/typo3_src/TYPO3_6-2/typo3/sysext/frontend/Classes/Page/PageRepository.php on line 1357

Since I’m no FAL expert, my best guess is to quit the function if $element isn’t an array before calling getFileReferences – but I would like some feedback before starting on a patch

Reviews 2