Code Duplication    Length = 12-13 lines in 3 locations

typo3/sysext/core/Classes/Database/ReferenceIndex.php 1 location

@@ 853-864 (lines=12) @@
850
        }
851
852
        // Collect file values in array:
853
        if ($conf['MM']) {
854
            $theFileValues = [];
855
            $dbAnalysis = GeneralUtility::makeInstance(RelationHandler::class);
856
            $dbAnalysis->start('', 'files', $conf['MM'], $uid);
857
            foreach ($dbAnalysis->itemArray as $someval) {
858
                if ($someval['id']) {
859
                    $theFileValues[] = $someval['id'];
860
                }
861
            }
862
        } else {
863
            $theFileValues = explode(',', $value);
864
        }
865
        // Traverse the files and add them:
866
        $uploadFolder = $conf['internal_type'] === 'file' ? $conf['uploadfolder'] : '';
867
        $destinationFolder = $this->destPathFromUploadFolder($uploadFolder);

typo3/sysext/core/Classes/DataHandling/DataHandler.php 2 locations

@@ 2212-2223 (lines=12) @@
2209
                    // Finding the CURRENT files listed, either from MM or from the current record.
2210
                    $theFileValues = [];
2211
                    // If MM relations for the files also!
2212
                    if ($tcaFieldConf['MM']) {
2213
                        $dbAnalysis = $this->createRelationHandlerInstance();
2214
                        /** @var $dbAnalysis RelationHandler */
2215
                        $dbAnalysis->start('', 'files', $tcaFieldConf['MM'], $id);
2216
                        foreach ($dbAnalysis->itemArray as $item) {
2217
                            if ($item['id']) {
2218
                                $theFileValues[] = $item['id'];
2219
                            }
2220
                        }
2221
                    } else {
2222
                        $theFileValues = GeneralUtility::trimExplode(',', $curValue, true);
2223
                    }
2224
                    $currentFilesForHistory = implode(',', $theFileValues);
2225
                    // DELETE files: If existing files were found, traverse those and register files for deletion which has been removed:
2226
                    if (!empty($theFileValues)) {
@@ 4088-4100 (lines=13) @@
4085
        }
4086
4087
        // Get an array with files as values:
4088
        if ($conf['MM']) {
4089
            $theFileValues = [];
4090
            /** @var $dbAnalysis RelationHandler */
4091
            $dbAnalysis = $this->createRelationHandlerInstance();
4092
            $dbAnalysis->start('', 'files', $conf['MM'], $uid);
4093
            foreach ($dbAnalysis->itemArray as $somekey => $someval) {
4094
                if ($someval['id']) {
4095
                    $theFileValues[] = $someval['id'];
4096
                }
4097
            }
4098
        } else {
4099
            $theFileValues = GeneralUtility::trimExplode(',', $value, true);
4100
        }
4101
        // Traverse this array of files:
4102
        $uploadFolder = $conf['internal_type'] === 'file' ? $conf['uploadfolder'] : '';
4103
        $dest = PATH_site . $uploadFolder;