Project

General

Profile

Bug #99442

Updated by Sybille Peters over 1 year ago

The problem is not only that the function behaves differently in FE and CLI but also that this is not reflected in the description (PHPDoc) and in the documentation. (Also, I assume it works in BE, but not in CLI). 

 I don't know why this relatively lowlevel function should behave differently based on context (and if this is still correct). 

 Documentation: 

 * https://docs.typo3.org/m/typo3/reference-coreapi/main/en-us/ApiOverview/Fal/UsingFal/ExamplesFileFolder.html#getting-referenced-files 

 > Getting Referenced files 
 > This snippet shows how to retrieve FAL items that have been attached to some other element, in this case the "media" field of the "pages" table: 

 <pre><code class="php"> 
 EXT:some_extension/Classes/SomeClass.php 
 use TYPO3\CMS\Core\Utility\GeneralUtility; 
 use TYPO3\CMS\Core\Resource\FileRepository; 

 $fileRepository = GeneralUtility::makeInstance(FileRepository::class); 
 $fileObjects = $fileRepository->findByRelation('pages', 'media', $uid); 

 </code></pre> 


 h2. Reproduce 

 Tested with TYPO3 v11.5.21 

 1. Create a field of type "inline" with file objects in Flexform of a content element 
 2. In a CLI command process the Flexform settings and try to get the file object (see code below) 
 3. Run command on command line. Try to process the $fileObjects 


 command: (extends Symfony\Component\Console\Command\Command): 

 <pre><code class="php"> 
 use TYPO3\CMS\Core\Resource\FileRepository; 
 use TYPO3\CMS\Core\Utility\GeneralUtility; 

 // .... 

 $fileRepository = GeneralUtility::makeInstance(FileRepository::class); 

 // .... 

 // this will return false 
 $fileObjects = $this->fileRepository->findByRelation('tt_content', 'pi_flexform', $uid); 


 </code></pre> 

Back