Bug #84542

No return value check in SoftReferenceParserHook

Added by Rens Admiraal over 3 years ago. Updated over 1 year ago.

Status:
Closed
Priority:
Should have
Assignee:
-
Category:
-
Target version:
-
Start date:
2018-03-27
Due date:
% Done:

0%

Estimated time:
TYPO3 Version:
8
PHP Version:
7.1
Tags:
Complexity:
Is Regression:
Sprint Focus:

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
                    ],
                ]
            ]
        ];

Related issues

Related to TYPO3 Core - Bug #89665: PHP error when updating database reference index after removing an extension that provided a form definitionClosed2019-11-13

Actions
#1

Updated by Rens Admiraal over 3 years ago

just found why I had this state, it was a copied database for testing purpose without the yaml definitions of forms.

#2

Updated by Riccardo De Contardi about 3 years ago

  • Status changed from New to Needs Feedback

@Rens Admiraal I feel sorry for this very late answer;

I've not understood if this issue can be closed or is there still work to do on this topic. If it is so, could you add a full guide about how to reproduce your issue? Thank you!

#3

Updated by Riccardo De Contardi almost 3 years ago

  • Status changed from Needs Feedback to Closed

No feedback since the last 90 days => closing this issue.

If you think that this is the wrong decision or experience the issue again and have more information about how to reproduce your problem, please reopen it or open a new issue with a reference to this one.

Thank you and best regards

#4

Updated by Rens Admiraal over 2 years ago

Hi Riccardo,

And then sorry for my late reply, I don't monitor my forge ;-)

But I don't know how to give a guide to reproduce the invalid state, but it's also not needed imho. \TYPO3\CMS\Form\Hooks\SoftReferenceParserHook::findRef calls ->getUid() on $file. $file is retrieved from \TYPO3\CMS\Core\Resource\ResourceFactory::retrieveFileOrFolderObject and this function has at minimum 2 ways to return null.

When \TYPO3\CMS\Core\Resource\ResourceFactory::retrieveFileOrFolderObject returns null the call to ->getUid() with fail with a fatal error "calling ->getUid() on null"

#5

Updated by Riccardo De Contardi over 2 years ago

  • Status changed from Closed to New

Reopened.

#6

Updated by Christian Eßl almost 2 years ago

This should have been fixed with #89665 in 9.5 and master.

#7

Updated by Christian Eßl almost 2 years ago

  • Related to Bug #89665: PHP error when updating database reference index after removing an extension that provided a form definition added
#8

Updated by Susanne Moog over 1 year ago

  • Status changed from New to Closed

This has been fixed with #89665.

Also available in: Atom PDF