[BUGFIX] Can not delete Files with metadata records 56/25456/3
authorFrans Saris <franssaris@gmail.com>
Sat, 16 Nov 2013 09:41:24 +0000 (10:41 +0100)
committerMarkus Klein <klein.t3@mfc-linz.at>
Thu, 21 Nov 2013 16:01:21 +0000 (17:01 +0100)
When a sys_file record has relation with a sys_file_metadata
record the file can not be deleted.

This patch excludes tables sys_file_metadata from the
reference check.

Resolves: #53672
Releases: 6.2
Change-Id: Ib7a5b55fce9f5cf19ffe3b18eddfc7238a8e8626
Reviewed-on: https://review.typo3.org/25456
Reviewed-by: Alexander Opitz
Tested-by: Alexander Opitz
Reviewed-by: Fabien Udriot
Reviewed-by: Markus Klein
Tested-by: Markus Klein
typo3/sysext/core/Classes/Utility/File/ExtendedFileUtility.php
typo3/sysext/filelist/Classes/FileList.php

index e1905b0..b859824 100644 (file)
@@ -387,12 +387,14 @@ class ExtendedFileUtility extends \TYPO3\CMS\Core\Utility\File\BasicFileUtility
                // @todo implement the recycler feature which has been removed from the original implementation
                // checks to delete the file
                if ($fileObject instanceof File) {
+                       // check if the file still has references
+                       // Exclude sys_file_metadata records as these are no use references
                        $refIndexRecords = $this->getDatabaseConnection()->exec_SELECTgetRows(
                                '*',
                                'sys_refindex',
                                'deleted=0 AND ref_table="sys_file" AND ref_uid=' . intval($fileObject->getUid())
+                               . ' AND tablename != "sys_file_metadata"'
                        );
-                       // check if the file still has references
                        if (count($refIndexRecords) > 0) {
                                $shortcutContent = array();
                                foreach ($refIndexRecords as $fileReferenceRow) {
index 5d8acae..d56e6c0 100644 (file)
@@ -875,8 +875,9 @@ class FileList extends \TYPO3\CMS\Backend\RecordList\AbstractRecordList {
                if ($fileOrFolderObject instanceof \TYPO3\CMS\Core\Resource\FolderInterface) {
                        return '-';
                }
-               // Look up the path:
-               $rows = $GLOBALS['TYPO3_DB']->exec_SELECTgetRows('*', 'sys_refindex', 'ref_table=\'sys_file\' AND ref_uid = ' . (integer)$fileOrFolderObject->getUid() . ' AND deleted=0');
+               // Look up the file in the sys_refindex.
+               // Exclude sys_file_metadata records as these are no use references
+               $rows = $GLOBALS['TYPO3_DB']->exec_SELECTgetRows('*', 'sys_refindex', 'ref_table=\'sys_file\' AND ref_uid = ' . (integer)$fileOrFolderObject->getUid() . ' AND deleted=0 AND tablename != "sys_file_metadata"');
                return $this->generateReferenceToolTip($rows, '\'_FILE\', ' . GeneralUtility::quoteJSvalue($fileOrFolderObject->getCombinedIdentifier()));
        }