Breaking: #97214 - Use UploadedFile objects instead of $_FILES¶
See forge#97214
Description¶
The TYPO3 request already contains a "disentangled" array of UploadedFile
objects. With this change, these UploadedFile objects are now used instead
of the superglobal $_FILES
in Extbase requests.
Additionally, the FAL ResourceStorage has been adjusted for handling UploadedFile objects and the ExtensionManager upload handling has been adjusted.
The next step would be to further adjust FAL to use only PSR provided methods for handling uploaded files and implementing an API for file uploads in Extbase.
Impact¶
The global $_FILES
object is not used in Extbase or the extension
manager anymore, instead the PSR request is used.
Affected Installations¶
All installations extending the TYPO3 Core ResourceStorage object and
overwriting the addUploadedFile
method.
Migration¶
Extension authors extending the TYPO3 Core resource storage and implementing
their own handling of addUploadedFile
need to allow objects of type
UploadedFile
in addition to the old array from global $_FILES
.
To do so, switch the type annotation to array|UploadedFile
and add code that
handles UploadedFile
objects and arrays.
Example¶
if ($uploadedFileData instanceof UploadedFile) {
$localFilePath = $uploadedFileData->getTemporaryFileName();
if ($targetFileName === null) {
$targetFileName = $uploadedFileData->getClientFilename();
}
$size = $uploadedFileData->getSize();
} else {
$localFilePath = $uploadedFileData['tmp_name'];
if ($targetFileName === null) {
$targetFileName = $uploadedFileData['name'];
}
$size = $uploadedFileData['size'];
}