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
$_
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
$_
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
add
method.
Migration
Extension authors extending the TYPO3 Core resource storage and implementing
their own handling of
add
need to allow objects of type
Uploaded
in addition to the old array from global
$_
.
To do so, switch the type annotation to
array
and add code that
handles
Uploaded
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'];
}