Commit 62af8f42 authored by Benni Mack's avatar Benni Mack Committed by Stefan Neufeind
Browse files

[BUGFIX] Catch exception when linked file is deleted

If a file is linked in the RTE, and the file is deleted afterwards
an exception is thrown, thus making it impossible to change
the link.

Instead, the popup should show up without selecting anything.

Resolves: #66624
Releases: master, 6.2
Change-Id: Iec985b0202002a2c906b4cee43cd4e27e496d4fb
Reviewed-on: http://review.typo3.org/41467


Reviewed-by: Georg Ringer's avatarGeorg Ringer <georg.ringer@gmail.com>
Tested-by: Georg Ringer's avatarGeorg Ringer <georg.ringer@gmail.com>
Reviewed-by: default avatarStefan Neufeind <typo3.neufeind@speedpartner.de>
Tested-by: default avatarStefan Neufeind <typo3.neufeind@speedpartner.de>
parent a2074903
......@@ -2258,16 +2258,26 @@ class ElementBrowser {
if (!StringUtility::beginsWith($href, 'file://') && strpos($href, 'file:') !== FALSE) {
$rel = substr($href, strpos($href, 'file:') + 5);
$rel = rawurldecode($rel);
// resolve FAL-api "file:UID-of-sys_file-record" and "file:combined-identifier"
$fileOrFolderObject = ResourceFactory::getInstance()->retrieveFileOrFolderObject($rel);
if ($fileOrFolderObject instanceof Folder) {
$info['act'] = 'folder';
$info['value'] = $fileOrFolderObject->getCombinedIdentifier();
} elseif ($fileOrFolderObject instanceof File) {
$info['act'] = 'file';
$info['value'] = $fileOrFolderObject->getUid();
} else {
$info['value'] = $rel;
try {
// resolve FAL-api "file:UID-of-sys_file-record" and "file:combined-identifier"
$fileOrFolderObject = ResourceFactory::getInstance()->retrieveFileOrFolderObject($rel);
if ($fileOrFolderObject instanceof Folder) {
$info['act'] = 'folder';
$info['value'] = $fileOrFolderObject->getCombinedIdentifier();
} elseif ($fileOrFolderObject instanceof File) {
$info['act'] = 'file';
$info['value'] = $fileOrFolderObject->getUid();
} else {
$info['value'] = $rel;
}
} catch (Exception\FileDoesNotExistException $e) {
// file was deleted or any other reason, don't select any item
if (MathUtility::canBeInterpretedAsInteger($rel)) {
$info['act'] = 'file';
} else {
$info['act'] = 'folder';
}
$info['value'] = '';
}
} elseif (StringUtility::beginsWith($href, $siteUrl)) {
// If URL is on the current frontend website:
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment