[BUGFIX] Fix refindex for FlexForm fields type group file_reference 97/28797/2
authorMarc Bastian Heinrichs <typo3@mbh-software.de>
Thu, 13 Mar 2014 16:56:00 +0000 (17:56 +0100)
committerMarc Bastian Heinrichs <typo3@mbh-software.de>
Tue, 15 Apr 2014 08:10:52 +0000 (10:10 +0200)
According to the fixes for the normal TCA fields of type "group"
internal_type "file_reference" in #49538 and #56353, this needs also
to be fixed for the FlexForm fields: handle the internal_type
file_reference as an db reference to sys_file.

Resolves: #56991
Releases: 6.2, 6.1, 6.0
Change-Id: Ie66c86c1bf3f0386d23259d0aee6706564beace3
Reviewed-on: https://review.typo3.org/28797
Reviewed-by: Marc Bastian Heinrichs
Tested-by: Marc Bastian Heinrichs
typo3/sysext/core/Classes/Database/ReferenceIndex.php

index ee5562f..e1bdead 100644 (file)
@@ -453,14 +453,33 @@ class ReferenceIndex {
                // Implode parameter values:
                list($table, $uid, $field) = array($PA['table'], $PA['uid'], $PA['field']);
                // Add files
-               if ($result = $this->getRelations_procFiles($dataValue, $dsConf, $uid)) {
-                       // Creates an entry for the field with all the files:
-                       $this->temp_flexRelations['file'][$structurePath] = $result;
+               $resultsFromFiles = $this->getRelations_procFiles($dataValue, $dsConf, $uid);
+               if (!empty($resultsFromFiles)) {
+                       // We have to fill different arrays here depending on the result.
+                       // internal_type file is still a relation of type file and
+                       // since http://forge.typo3.org/issues/49538 internal_type file_reference
+                       // is a database relation to a sys_file record
+                       $fileResultsFromFiles = array();
+                       $dbResultsFromFiles = array();
+                       foreach ($resultsFromFiles as $resultFromFiles) {
+                               if (isset($resultFromFiles['table']) && $resultFromFiles['table'] === 'sys_file') {
+                                       $dbResultsFromFiles[] = $resultFromFiles;
+                               } else {
+                                       $fileResultsFromFiles[] = $resultFromFiles;
+                               }
+                       }
+                       if (!empty($fileResultsFromFiles)) {
+                               $this->temp_flexRelations['file'][$structurePath] = $fileResultsFromFiles;
+                       }
+                       if (!empty($dbResultsFromFiles)) {
+                               $this->temp_flexRelations['db'][$structurePath] = $dbResultsFromFiles;
+                       }
                }
                // Add DB:
-               if ($result = $this->getRelations_procDB($dataValue, $dsConf, $uid, $field)) {
+               $resultsFromDatabase = $this->getRelations_procDB($dataValue, $dsConf, $uid, $field);
+               if (!empty($resultsFromDatabase)) {
                        // Create an entry for the field with all DB relations:
-                       $this->temp_flexRelations['db'][$structurePath] = $result;
+                       $this->temp_flexRelations['db'][$structurePath] = $resultsFromDatabase;
                }
                // Soft References:
                if (strlen($dataValue) && ($softRefs = \TYPO3\CMS\Backend\Utility\BackendUtility::explodeSoftRefParserList($dsConf['softref']))) {
@@ -949,4 +968,4 @@ class ReferenceIndex {
 }
 
 
-?>
\ No newline at end of file
+?>