[BUG] Deleting a file is impossible after it was used
authorBenjamin Mack <benni@typo3.org>
Tue, 9 Oct 2012 12:32:27 +0000 (14:32 +0200)
committerHelmut Hummel <helmut.hummel@typo3.org>
Tue, 9 Oct 2012 16:05:31 +0000 (18:05 +0200)
The sys_refindex db table has a deleted column which is set
however when deleting a file, extfilefunc mentions that the
file is still in use. The extfilefunc check now takes the deleted
column into account.

Change-Id: If56178766c761309b2f4d2e7988399209fcc2480
Releases: 6.0
Resolves: #41115
Reviewed-on: http://review.typo3.org/15436
Reviewed-by: Steffen Ritter
Tested-by: Steffen Ritter
Reviewed-by: Helmut Hummel
Tested-by: Helmut Hummel
typo3/sysext/core/Classes/Utility/File/ExtendedFileUtility.php

index 145caea..fdafa09 100644 (file)
@@ -383,9 +383,14 @@ class ExtendedFileUtility extends \TYPO3\CMS\Core\Utility\File\BasicFileUtility
                // for backwards compatibility: the combined file identifier was the path+filename
                $fileObject = $this->getFileObject($cmds['data']);
                // @todo implement the recycler feature which has been removed from the original implementation
-               // Copies the file
+               // checks to delete the file
                if ($fileObject instanceof \TYPO3\CMS\Core\Resource\File) {
-                       $refIndexRecords = $GLOBALS['TYPO3_DB']->exec_SELECTgetRows('*', 'sys_refindex', 'ref_table=\'sys_file\' AND ref_uid=' . $fileObject->getUid());
+                       $refIndexRecords = $GLOBALS['TYPO3_DB']->exec_SELECTgetRows(
+                               '*',
+                               'sys_refindex',
+                               'deleted=0 AND ref_table="sys_file" AND ref_uid=' . intval($fileObject->getUid())
+                       );
+                       // check if the file still has references
                        if (count($refIndexRecords) > 0) {
                                $shortcutContent = array();
                                foreach ($refIndexRecords as $row) {