diff --git a/typo3/sysext/core/Classes/Utility/File/ExtendedFileUtility.php b/typo3/sysext/core/Classes/Utility/File/ExtendedFileUtility.php
index add97d6..db5ed14 100644
--- a/typo3/sysext/core/Classes/Utility/File/ExtendedFileUtility.php
+++ b/typo3/sysext/core/Classes/Utility/File/ExtendedFileUtility.php
@@ -390,48 +390,71 @@ class ExtendedFileUtility extends \TYPO3\CMS\Core\Utility\File\BasicFileUtility
);
if (count($refIndexRecords) > 0) {
$shortcutContent = array();
+ $brokenReferences = array();
+
foreach ($refIndexRecords as $fileReferenceRow) {
- $row = $fileReferenceRow;
if ($fileReferenceRow['tablename'] === 'sys_file_reference') {
$row = $this->transformFileReferenceToRecordReference($fileReferenceRow);
+ $shortcutRecord = BackendUtility::getRecord($row['tablename'], $row['recuid']);
+
+ if ($shortcutRecord) {
+ $icon = \TYPO3\CMS\Backend\Utility\IconUtility::getSpriteIconForRecord($row['tablename'], $shortcutRecord);
+ $onClick = 'Clickmenu.show("' . $row['tablename'] . '", "' . $row['recuid'] . '", "1", "+info,history,edit", "|", "");return false;';
+ $shortcutContent[] = '' . $icon . '' . htmlspecialchars((BackendUtility::getRecordTitle($row['tablename'], $shortcutRecord) . ' [' . BackendUtility::getRecordPath($shortcutRecord['pid'], '', 80) . ']'));
+
+ } else {
+ $brokenReferences[] = $fileReferenceRow['ref_uid'];
+ }
}
- $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[] = '' . $icon . '' . htmlspecialchars((BackendUtility::getRecordTitle($row['tablename'], $shortcutRecord) . ' [' . BackendUtility::getRecordPath($shortcutRecord['pid'], '', 80) . ']'));
}
- // render a message that the file could not be deleted
- $flashMessage = GeneralUtility::makeInstance(
- '\\TYPO3\\CMS\\Core\\Messaging\\FlashMessage',
- sprintf($GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xlf:message.description.fileNotDeletedHasReferences'), $fileObject->getName()) . '
' . implode('
', $shortcutContent),
- $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xlf:message.header.fileNotDeletedHasReferences'),
- \TYPO3\CMS\Core\Messaging\FlashMessage::WARNING,
- TRUE
- );
- $this->addFlashMessage($flashMessage);
- } else {
- try {
- $result = $fileObject->delete();
-
- // show the user that the file was deleted
+ if (!empty($shortcutContent)) {
+ // render a message that the file could not be deleted
$flashMessage = GeneralUtility::makeInstance(
'\\TYPO3\\CMS\\Core\\Messaging\\FlashMessage',
- sprintf($GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xlf:message.description.fileDeleted'), $fileObject->getName()),
- $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xlf:message.header.fileDeleted'),
- \TYPO3\CMS\Core\Messaging\FlashMessage::OK,
+ sprintf($GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xlf:message.description.fileNotDeletedHasReferences'), $fileObject->getName()) . '
' . implode('
', $shortcutContent),
+ $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xlf:message.header.fileNotDeletedHasReferences'),
+ \TYPO3\CMS\Core\Messaging\FlashMessage::WARNING,
+ TRUE
+ );
+ $this->addFlashMessage($flashMessage);
+ }
+ if (!empty($brokenReferences)) {
+ // render a message that the file has broken references
+ $flashMessage = GeneralUtility::makeInstance(
+ '\\TYPO3\\CMS\\Core\\Messaging\\FlashMessage',
+ sprintf($GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xlf:message.description.fileHasBrokenReferences'), count($brokenReferences)),
+ $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xlf:message.header.fileHasBrokenReferences'),
+ \TYPO3\CMS\Core\Messaging\FlashMessage::INFO,
TRUE
);
$this->addFlashMessage($flashMessage);
- // Log success
- $this->writelog(4, 0, 1, 'File "%s" deleted', array($fileObject->getIdentifier()));
- } catch (\TYPO3\CMS\Core\Resource\Exception\InsufficientFileAccessPermissionsException $e) {
- $this->writelog(4, 1, 112, 'You are not allowed to access the file', array($fileObject->getIdentifier()));
- } catch (\TYPO3\CMS\Core\Resource\Exception\NotInMountPointException $e) {
- $this->writelog(4, 1, 111, 'Target was not within your mountpoints! T="%s"', array($fileObject->getIdentifier()));
- } catch (\RuntimeException $e) {
- $this->writelog(4, 1, 110, 'Could not delete file "%s". Write-permission problem?', array($fileObject->getIdentifier()));
}
+
+ // return here without deleting the file
+ return $result;
+ }
+
+ try {
+ $result = $fileObject->delete();
+
+ // show the user that the file was deleted
+ $flashMessage = GeneralUtility::makeInstance(
+ '\\TYPO3\\CMS\\Core\\Messaging\\FlashMessage',
+ sprintf($GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xlf:message.description.fileDeleted'), $fileObject->getName()),
+ $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xlf:message.header.fileDeleted'),
+ \TYPO3\CMS\Core\Messaging\FlashMessage::OK,
+ TRUE
+ );
+ $this->addFlashMessage($flashMessage);
+ // Log success
+ $this->writelog(4, 0, 1, 'File "%s" deleted', array($fileObject->getIdentifier()));
+ } catch (\TYPO3\CMS\Core\Resource\Exception\InsufficientFileAccessPermissionsException $e) {
+ $this->writelog(4, 1, 112, 'You are not allowed to access the file', array($fileObject->getIdentifier()));
+ } catch (\TYPO3\CMS\Core\Resource\Exception\NotInMountPointException $e) {
+ $this->writelog(4, 1, 111, 'Target was not within your mountpoints! T="%s"', array($fileObject->getIdentifier()));
+ } catch (\RuntimeException $e) {
+ $this->writelog(4, 1, 110, 'Could not delete file "%s". Write-permission problem?', array($fileObject->getIdentifier()));
}
} else {
try {
diff --git a/typo3/sysext/lang/locallang_core.xlf b/typo3/sysext/lang/locallang_core.xlf
index 7a7188a..2ece523 100644
--- a/typo3/sysext/lang/locallang_core.xlf
+++ b/typo3/sysext/lang/locallang_core.xlf
@@ -753,6 +753,12 @@ Would you like to save now in order to refresh the display?
+
+
+
+