Project

General

Profile

Actions

Bug #99442

open

FileRepository::findByRelation() works differently in FE or other contexts and will not return the file reference objects in CLI context

Added by Sybille Peters almost 2 years ago. Updated almost 2 years ago.

Status:
New
Priority:
Should have
Assignee:
-
Category:
File Abstraction Layer (FAL)
Target version:
-
Start date:
2023-01-01
Due date:
% Done:

0%

Estimated time:
TYPO3 Version:
11
PHP Version:
Tags:
Complexity:
Is Regression:
Sprint Focus:

Description

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:

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:

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);

Reproduce

Tested with TYPO3 v11.5.21

It is possible to reproduce with this extension: https://github.com/sypets/sypets_example_findbyrelation_cli

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):

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);


Related issues 2 (1 open1 closed)

Related to TYPO3 Core - Bug #61344: findByRelation() does not work since 6.2.4Closed2014-09-04

Actions
Related to TYPO3 Core - Bug #104331: \TYPO3\CMS\Core\Resource\FileRepository::findByRelation incapable of handling FAL relations in FlexForm in BE contextNew2024-07-08

Actions
Actions #1

Updated by Sybille Peters almost 2 years ago

  • Description updated (diff)
Actions #2

Updated by Sybille Peters almost 2 years ago

  • Related to Bug #61344: findByRelation() does not work since 6.2.4 added
Actions #3

Updated by Sybille Peters almost 2 years ago

  • Description updated (diff)
Actions #4

Updated by Sybille Peters almost 2 years ago

It is possible to reproduce with this extension: https://github.com/sypets/sypets_example_findbyrelation_cli

Actions #5

Updated by Claus Due 5 months ago

  • Related to Bug #104331: \TYPO3\CMS\Core\Resource\FileRepository::findByRelation incapable of handling FAL relations in FlexForm in BE context added
Actions

Also available in: Atom PDF