#111357PHP Warning: Undefined array key "data" in ExtendedFileUtility::replaceFile()
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:
- data[replace]1[keepFilename]
- file replace_1
- 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:
- Backend > Filelist > open the context menu of a file > “Replace”
- 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
- 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
-
Gerrit Code Review pushed patch set 1 for main to change 97387 status
NewUnder Review <span data-processor="relativetime" data-value="2026-11-06T09:10:31+00:00" > 11/06/26, 09:10 </span> -
Gerrit Code Review pushed patch set 1 for 14.3 to change 97388 <span data-processor="relativetime" data-value="2026-11-06T09:10:55+00:00" > 11/06/26, 09:10 </span>
-
Gerrit Code Review pushed patch set 2 for 14.3 to change 97388 <span data-processor="relativetime" data-value="2026-11-06T20:18:13+00:00" > 11/06/26, 20:18 </span>
-
Benni Mack commented and changed status
Under ReviewResolved done0 %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.