Issue Bug Closed

#84542No return value check in SoftReferenceParserHook

Rens Admiraal 03/27/18, 19:19 updated 03/26/20, 08:19

Description

I currently seem to have an invalid state in a TYPO3 database, which causes an exception while updating the reference index. I will take care of fixing my database, but by reading the code I do think there’s a lacking return value check in the SoftReferenceParserHook.

It’s about line sysext/form/Classes/Hooks/SoftReferenceParserHook.php:59 calling $file->getUid() while $file can be null.

$resourceFactory = GeneralUtility::makeInstance(ResourceFactory::class);
        $file = $resourceFactory->retrieveFileOrFolderObject($content);

        return [
            'content' => '{softref:' . $tokenId . '}',
            'elements' => [
                $tokenId => [
                    'matchString' => $content,
                    'subst' => [
                        'type' => 'db',
                        'recordRef' => 'sys_file:' . $file->getUid(),
                        'tokenID' => $tokenId,
                        'tokenValue' => $content
                    ],
                ]
            ]
        ];

Reviews 0

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