Project

General

Profile

Actions

Feature #90374

open

Add setOriginaFile / setFile setter to TYPO3\CMS\Extbase\Domain\Model\FileReference

Added by This Mächler about 4 years ago. Updated about 1 year ago.

Status:
Under Review
Priority:
Should have
Assignee:
-
Category:
File Abstraction Layer (FAL)
Start date:
2020-02-15
Due date:
% Done:

0%

Estimated time:
PHP Version:
Tags:
FAL FileReference Extbase Create setOriginalResource
Complexity:
no-brainer
Sprint Focus:

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!


Related issues 5 (2 open3 closed)

Related to TYPO3 Core - Feature #88833: Extend possibility to create FileReference in frontend with a given File objectUnder Review2019-07-24

Actions
Related to TYPO3 Core - Bug #66813: Persisting extbase FileReference does not work with default TCA configurationClosedStefan Froemken2015-05-06

Actions
Related to TYPO3 Core - Bug #90373: Persisting FileReference in Extbase leads to empty 'table_local' field in sys_file_referenceClosed2020-02-15

Actions
Related to TYPO3 Core - Bug #48965: FileReference can't be created in Frontend contextClosed2013-06-08

Actions
Related to TYPO3 Core - Bug #78044: Can't create \TYPO3\CMS\Extbase\Domain\Model\FileReference from \TYPO3\CMS\Core\Resource\File nor from \TYPO3\CMS\Extbase\Domain\Model\FileUnder Review2016-09-22

Actions
Actions #1

Updated by Christian Eßl about 4 years ago

  • Related to Feature #88833: Extend possibility to create FileReference in frontend with a given File object added
Actions #2

Updated by Christian Eßl about 4 years ago

  • Related to Bug #66813: Persisting extbase FileReference does not work with default TCA configuration added
Actions #3

Updated by Christian Eßl about 4 years ago

  • Related to Bug #90373: Persisting FileReference in Extbase leads to empty 'table_local' field in sys_file_reference added
Actions #4

Updated by Christian Eßl about 4 years ago

  • Related to Bug #48965: FileReference can't be created in Frontend context added
Actions #5

Updated by Christian Eßl about 4 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
Actions #6

Updated by Mathias Schreiber about 2 years ago

  • Sprint Focus set to Remote Sprint
Actions #7

Updated by Susanne Moog over 1 year ago

  • Sprint Focus changed from Remote Sprint to On Location Sprint
Actions #8

Updated by Oliver Hader over 1 year ago

  • Sprint Focus deleted (On Location Sprint)
Actions #9

Updated by Gerrit Code Review about 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

Actions

Also available in: Atom PDF