Issue Bug Closed

#109103ExtendedFileUtility::func_delete() crashes with TypeError when sys_file_reference record is missing or has NULL tablenames

Rico Sonntag 02/26/26, 07:19 updated 03/31/26, 08:09

Description

Problem

Deleting a file via the File > Filelist backend module fails with a 503 error when {{sys_refindex}} contains entries pointing to {{sys_file_reference}} records that either no longer
exist or have a NULL {{tablenames}} field.

{code}
TYPO3\CMS\Backend\Utility\BackendUtility::getRecord(): Argument #1 ($table) must be of type string, null given,
called in vendor/typo3/cms-core/Classes/Utility/File/ExtendedFileUtility.php on line 394
{code}

Note: The existing “broken references” handling (flash message + delete anyway) works correctly when the target record (e.g. tt_content) is missing but the {{sys_file_reference}}
still exists. This bug only occurs when the {{sys_file_reference}} record itself is missing or has NULL in the {{tablenames}} column.

Root cause

In {{transformFileReferenceToRecordReference()}} (line 554-578), {{fetchAssociative()}} returns {{false}} when the {{sys_file_reference}} record does not exist. The method accesses
array keys on {{false}} without checking:

{code:php}
$fileReference = $queryBuilder->…->fetchAssociative();

// No check for $fileReference === false
return [
‘recuid’ => $fileReference[‘uid_foreign’], // null
‘tablename’ => $fileReference[‘tablenames’], // null
…
];
{code}

This causes {{BackendUtility::getRecord(null, null)}} on line 394, which throws a TypeError.

Steps to reproduce

  1. Create a content element with a file reference
  2. Delete the {{sys_file_reference}} record directly in the database (or cause a NULL {{tablenames}} field)
  3. Try to delete the file via File > Filelist in the backend
  4. 503 error occurs

The stale {{sys_refindex}} entry from before the deletion still points to the now-missing {{sys_file_reference}} UID, triggering the bug.

Suggested fix

Add a false/null check in {{transformFileReferenceToRecordReference()}}:

{code:php}
$fileReference = $queryBuilder->…->fetchAssociative();

if ($fileReference === false) {
return null;
}
{code}

And in {{func_delete()}}, handle the null return:

{code:php}
$row = $this->transformFileReferenceToRecordReference($fileReferenceRow);
if ($row === null) {
$brokenReferences[] = $fileReferenceRow[‘ref_uid’];
continue;
}
$shortcutRecord = BackendUtility::getRecord($row[‘tablename’], $row[‘recuid’]);
{code}

This way, missing or broken {{sys_file_reference}} records are treated as broken references (same flash message, file still gets deleted).

Workaround

Rebuild the reference index to remove orphaned entries:

{code}
vendor/bin/typo3 referenceindex:update
{code}

Reviews 2