[BUGFIX] Missing and invalid warnings on referenced files 04/30204/4
authorOliver Hader <oliver@typo3.org>
Mon, 19 May 2014 10:02:36 +0000 (12:02 +0200)
committerWouter Wolters <typo3@wouterwolters.nl>
Thu, 23 Oct 2014 21:48:41 +0000 (23:48 +0200)
The file list module in the backend offers the possibility to
delete files. An interesting use case is the deletion of files
that still have references to other entities. However, currently
proper warnings are only available for sys_file reference.

a) before deleting a file, a popup should be shown
   this does not work since the API is called with
   the identifier instead of a proper UID value

b) after calling the API for deleting a file, references
   should be pointed out
   references are checked, however the description on the
   file usage is missing due to hardcoded "sys_file_reference"
   triggers - thus, no other references are printed out

Resolves: #58913
Releases: master, 6.2, 6.1
Change-Id: Id80361427abc17bda3461c2d00750c4790798c88
Reviewed-on: http://review.typo3.org/30204
Reviewed-by: Wouter Wolters <typo3@wouterwolters.nl>
Tested-by: Wouter Wolters <typo3@wouterwolters.nl>
typo3/sysext/core/Classes/Utility/File/ExtendedFileUtility.php
typo3/sysext/filelist/Classes/FileList.php

index fcbbc0e..148b2a8 100644 (file)
@@ -391,13 +391,14 @@ class ExtendedFileUtility extends \TYPO3\CMS\Core\Utility\File\BasicFileUtility
                        if (count($refIndexRecords) > 0) {
                                $shortcutContent = array();
                                foreach ($refIndexRecords as $fileReferenceRow) {
+                                       $row = $fileReferenceRow;
                                        if ($fileReferenceRow['tablename'] === 'sys_file_reference') {
                                                $row = $this->transformFileReferenceToRecordReference($fileReferenceRow);
-                                               $shortcutRecord = BackendUtility::getRecord($row['tablename'], $row['recuid']);
-                                               $icon = \TYPO3\CMS\Backend\Utility\IconUtility::getSpriteIconForRecord($row['tablename'], $shortcutRecord);
-                                               $onClick = 'Clickmenu.show("' . $row['tablename'] . '", "' . $row['recuid'] . '", "1", "+info,history,edit", "|", "");return false;';
-                                               $shortcutContent[] = '<a href="#" oncontextmenu="this.click();return false;" onclick="' . htmlspecialchars($onClick) . '">' . $icon . '</a>' . htmlspecialchars((BackendUtility::getRecordTitle($row['tablename'], $shortcutRecord) . '  [' . BackendUtility::getRecordPath($shortcutRecord['pid'], '', 80) . ']'));
                                        }
+                                       $shortcutRecord = BackendUtility::getRecord($row['tablename'], $row['recuid']);
+                                       $icon = \TYPO3\CMS\Backend\Utility\IconUtility::getSpriteIconForRecord($row['tablename'], $shortcutRecord);
+                                       $onClick = 'Clickmenu.show("' . $row['tablename'] . '", "' . $row['recuid'] . '", "1", "+info,history,edit", "|", "");return false;';
+                                       $shortcutContent[] = '<a href="#" oncontextmenu="this.click();return false;" onclick="' . htmlspecialchars($onClick) . '">' . $icon . '</a>' . htmlspecialchars((BackendUtility::getRecordTitle($row['tablename'], $shortcutRecord) . '  [' . BackendUtility::getRecordPath($shortcutRecord['pid'], '', 80) . ']'));
                                }
 
                                // render a message that the file could not be deleted
index 125951c..2567330 100644 (file)
@@ -804,7 +804,7 @@ class FileList extends \TYPO3\CMS\Backend\RecordList\AbstractRecordList {
                        if ($fileOrFolderObject instanceof \TYPO3\CMS\Core\Resource\Folder) {
                                $referenceCountText = BackendUtility::referenceCount('_FILE', $identifier, ' (There are %s reference(s) to this folder!)');
                        } else {
-                               $referenceCountText = BackendUtility::referenceCount('sys_file', $identifier, ' (There are %s reference(s) to this file!)');
+                               $referenceCountText = BackendUtility::referenceCount('sys_file', $fileOrFolderObject->getUid(), ' (There are %s reference(s) to this file!)');
                        }
 
                        if ($GLOBALS['BE_USER']->jsConfirmation(4)) {