Issue Bug Resolved

#111357PHP Warning: Undefined array key "data" in ExtendedFileUtility::replaceFile()

Sebastian Stein 11/06/26, 07:26 updated 11/06/26, 20:35

Description

ExtendedFileUtility::replaceFile() reads $cmdArr[‘data’] without checking whether the key exists:

protected function replaceFile(array $cmdArr)                                                                                                                                                                                                                                  
{                                                                                                                                                                                                                                                                              
    $fileObjectToReplace = null;                                                                                                                                                                                                                                               
    $uploadPosition = $cmdArr['data'];                                                                                                                                                                                                                                         
    $fileInfo = $_FILES['replace_' . $uploadPosition];                                                                                                                                                                                                                         
    if (empty($fileInfo['name'])) 
{

(typo3/sysext/core/Classes/Utility/File/ExtendedFileUtility.php, this is present in main aswell as 13.4)

We got this warning in production:

PHP Warning: Undefined array key “data” in …/typo3/cms-core/Classes/Utility/File/ExtendedFileUtility.php line 1128

Since E_WARNING is part of exceptionalErrors by default, the editor gets an exception instead of the existing flash message “No file was uploaded for replacing”.

Probable cause:

The “Replace file” form (EXT:filelist/Resources/Private/Templates/File/ReplaceFile.html) sends its fields in this order:

  1. data[replace]1[keepFilename]
  2. file replace_1
  3. data[replace]1[data] and data[replace]1[uid] (hidden fields after the file input)

If the multipart request is cut off while the file is being transferred (connection aborted, proxy or upload timeout, max_input_time reached), PHP only parses the fields that arrived before the file. The command array is then [‘keepFilename’ => ‘1’] without data and uid, and replaceFile() runs into the warning.

The other commands already handle missing values: start()/processData() check upload and newfolder with $cmdArr[‘data’] ?? ‘’.

Steps to reproduce:

  1. Backend > Filelist > open the context menu of a file > “Replace”
  2. Pick a large file and cancel the request during the upload (e.g. throttle the network in the browser DevTools and close the connection/tab), or let it run into a server-side timeout
  3. See the warning or exception in the log

Expected behaviour:

No PHP warning. The method stops with the existing message “No file was uploaded for replacing”.

Suggested fix:

for main

$uploadPosition = (string)($cmdArr['data'] ?? '');
$uploadedFile = $this->uploadedFiles['replace_' . $uploadPosition] ?? null;
if ($uploadPosition === ''
    || !$uploadedFile instanceof UploadedFileInterface
    || empty($uploadedFile->getClientFilename())
) {
    // existing log + flash message, return false
}

for 13.4

$uploadPosition = (string)($cmdArr['data'] ?? '');
$fileInfo = $_FILES['replace_' . $uploadPosition] ?? [];
if ($uploadPosition === '' || empty($fileInfo['name'])) {
    // existing log + flash message, return false
}

Reviews 2

History 14

  1. Benni Mack commented and changed status Under Review Resolved done 0 % 100 % <span data-processor="relativetime" data-value="2026-11-06T20:35:10+00:00" > 11/06/26, 20:35 </span>

    Applied in changeset commit:21bb961041de3ccd765da8713c30515395180e0b.