Project

General

Profile

Actions

Bug #61344

closed

findByRelation() does not work since 6.2.4

Added by Armin Vieweg over 9 years ago. Updated over 1 year ago.

Status:
Closed
Priority:
Should have
Assignee:
-
Category:
File Abstraction Layer (FAL)
Target version:
-
Start date:
2014-09-04
Due date:
% Done:

0%

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

Description

Hello,

several users of the DCE extension mentioned, that the output of FAL images in backend does not work anymore, since they've updated to TYPO3 6.2.4. In previous version it worked.

I don't know why, but somehow the following call will not return any results anymore:

$fileRepository = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\Resource\\FileRepository');
return $fileRepository->findByRelation('tt_content', $field, $contentObject['uid']);
Of course the entries are existing. A manual get of the relation entries works:
$contentObjectUid = intval($contentObject['uid']);
/** @var t3lib_DB $typo3Database */
$typo3Database = Tx_Dce_Utility_DatabaseUtility::getDatabaseConnection();
$rows = $typo3Database->exec_SELECTgetRows(
    'uid',
    'sys_file_reference',
    'tablenames = "tt_content" AND uid_foreign = ' . $contentObjectUid . ' AND fieldname = "' . $field . '"'
);
And with findFileReferenceByUid() I'll get the reference objects.

I'm using now this manual way of getting the references in my FalViewHelper.


Related issues 1 (1 open0 closed)

Related to TYPO3 Core - Bug #99442: FileRepository::findByRelation() works differently in FE or other contexts and will not return the file reference objects in CLI contextNew2023-01-01

Actions
Actions #1

Updated by Armin Vieweg over 9 years ago

Oh, I should mention that it just not works in backend context. In frontend it still seems to work. I've seen in this findByRelation() method is an if condition which checks the environment. Probably there is a bug in the else part, which represents the backend environment.

Actions #2

Updated by Stefan Neufeind over 9 years ago

it seems that "else" is in sysext/core/Classes/Resource/FileRepository.php

Actions #3

Updated by Armin Vieweg over 9 years ago

Yes, I am talking about the FileRepository object and its findByRelation() method. It contains an if condition checking the environment (FE or BE). The FE part works. The BE part not. But just since 6.2.4. In 6.2.3 everything worked fine.

Actions #4

Updated by Online Now! GmbH about 9 years ago

I can confirm this bug with TYPO 6.2.12. I am not able to get referenced files in a backend module with the findByRelation() function. The field i defined is a flexform field and not in the TCA. Might be the cause for this? I dont have the time at the moment to investigate this further.

Workaround is to get the relations manually.

Actions #5

Updated by Klaus Hörmann-Engl almost 9 years ago

I can confirm this Bug with TYPO3 6.2.13. I tried to load referenced files in a backend TemplaVoila hook, for display in the backend. No fileReferences are returned.

Actions #6

Updated by Hendrik N over 8 years ago

Bug still there in 6.2.14. I dont get the FE/BE else part anyways, TSFE is just used for enableFields. What about:

$enableFields = $this->getEnvironmentMode() === 'FE' && !empty($GLOBALS['TSFE']->sys_page) ?
    $GLOBALS['TSFE']->sys_page->enableFields('sys_file_reference', $GLOBALS['TSFE']->showHiddenRecords) :
    \TYPO3\CMS\Backend\Utility\BackendUtility::BEenableFields('sys_file_reference');

$references = $this->getDatabaseConnection()->exec_SELECTgetRows(
    'uid',
    'sys_file_reference',
    'tablenames=' . $this->getDatabaseConnection()->fullQuoteStr($tableName, 'sys_file_reference') .
    ' AND uid_foreign=' . (int)$uid .
    ' AND fieldname=' . $this->getDatabaseConnection()->fullQuoteStr($fieldName, 'sys_file_reference')
    . $enableFields,
    '',
    'sorting_foreign',
    '',
    'uid'
);
if (!empty($references)) {
    $referenceUids = array_keys($references);
}
Actions #7

Updated by Rico Sonntag almost 7 years ago

  • Category set to File Abstraction Layer (FAL)
Actions #8

Updated by Rico Sonntag almost 7 years ago

  • Category deleted (File Abstraction Layer (FAL))
Actions #9

Updated by Riccardo De Contardi over 6 years ago

  • Category set to File Abstraction Layer (FAL)
  • Status changed from New to Needs Feedback

Can someone tell us if this still happen with 7.6.x or 8.7.x ?

Actions #10

Updated by Riccardo De Contardi about 6 years ago

  • Status changed from Needs Feedback to Closed

No feedback since the last 90 days => closing this issue.

If you think that this is the wrong decision or experience the issue again, please reopen it or open a new issue with a reference to this one. Thank you.

Actions #11

Updated by Sybille Peters over 1 year ago

  • Related to Bug #99442: FileRepository::findByRelation() works differently in FE or other contexts and will not return the file reference objects in CLI context added
Actions #12

Updated by Sybille Peters over 1 year ago

Why does this have "Needs Feedback" set and is closed?

I just reported a bug #99442 which looks very much similar if not duplicate (though I noticed the problem in CLI context, not in BE context).

Actions

Also available in: Atom PDF