Feature #90374
closedAdd setOriginaFile / setFile setter to TYPO3\CMS\Extbase\Domain\Model\FileReference
0%
Description
Creating a new file reference in frontend context is not properly possible right now.
I read this tutorial that describes the issue:
https://docs.typo3.org/m/typo3/reference-coreapi/master/en-us/ApiOverview/Fal/UsingFal/ExamplesFileFolder.html?highlight=file%20reference#in-the-frontend-context
And studied this example:
"A cleaner solution using Extbase requires far more work. An example can be found here: https://github.com/helhum/upload_example"
The problem is, that this approach is not clean. resourceFactory->createFileReferenceObject creates a dead useless sys_file_reference - record in the database (with just a relation to the file, but not to any foreign table record) each time a new file-reference is created. This is only necessary to provide a 'originalResource' to the TYPO3\CMS\Extbase\Domain\Model\FileReference, which does noting else than fetching the original file from the useless ghos-file-reference:
public function setOriginalResource(\TYPO3\CMS\Core\Resource\ResourceInterface $originalResource)
{
$this->originalResource = $originalResource;
$this->uidLocal = (int)$originalResource->getOriginalFile()->getUid();
}
This could be avoided by just adding a public function to set the file directly to the reference (which makes a lot of sense?):
public function setOriginalFile(\TYPO3\CMS\Core\Resource\File $originalFile)
{
$this->uidLocal = (int)$originalFile->getUid();
}
Just now you have to create your own class derived from TYPO3\CMS\Extbase\Domain\Model\FileReference and add this setter to avoid creating a dead record.
Second problem comes on persisting the file reference by the exbase framework, the created record does have an empty 'table_local' field, which leads to improper handling of the reference in the backend, see here: https://forge.typo3.org/issues/90373
Would be nice to have this fixed, making FAL work properly with extbase!
Updated by Christian Eßl almost 5 years ago
- Related to Feature #88833: Extend possibility to create FileReference in frontend with a given File object added
Updated by Christian Eßl almost 5 years ago
- Related to Bug #66813: Persisting extbase FileReference does not work with default TCA configuration added
Updated by Christian Eßl almost 5 years ago
- Related to Bug #90373: Persisting FileReference in Extbase leads to empty 'table_local' field in sys_file_reference added
Updated by Christian Eßl almost 5 years ago
- Related to Bug #48965: FileReference can't be created in Frontend context added
Updated by Christian Eßl almost 5 years ago
- Related to Bug #78044: Can't create \TYPO3\CMS\Extbase\Domain\Model\FileReference from \TYPO3\CMS\Core\Resource\File nor from \TYPO3\CMS\Extbase\Domain\Model\File added
Updated by Susanne Moog over 2 years ago
- Sprint Focus changed from Remote Sprint to On Location Sprint
Updated by Oliver Hader about 2 years ago
- Sprint Focus deleted (
On Location Sprint)
Updated by Gerrit Code Review over 1 year ago
- Status changed from New to Under Review
Patch set 2 for branch main of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/78166
Updated by Georg Ringer 4 months ago
- Status changed from Under Review to Closed
closed as duplicate of #88833
Updated by Gerrit Code Review 4 months ago
- Status changed from Closed to Under Review
Patch set 3 for branch main of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/78166
Updated by Gerrit Code Review 4 months ago
Patch set 4 for branch main of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/78166
Updated by Gerrit Code Review 4 months ago
Patch set 5 for branch main of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/78166
Updated by Georg Ringer 4 months ago
- Status changed from Under Review to Closed