Skip to content

Commit

Permalink
[BUGFIX] Only allow to edit metadata in FileList if metadata exists
Browse files Browse the repository at this point in the history
The pencil icon on the file list should only show up if
a metadata record exists, in order to avoid an error.

This case happens if a file wasn't indexed correctly
and the Indexer cannot open the file to create metadata
via the Scheduler, e.g. if the folder of the file has
an invalid character, such as "(blabla)" as suffix and
was uploaded externally via FTP.

Resolves: #94743
Releases: 10.4
Change-Id: I99e23cefc82591fa0562072d61bcc74f72b49b6f
Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/70284
Reviewed-by: Wouter Wolters <typo3@wouterwolters.nl>
Reviewed-by: Daniel Goerz <daniel.goerz@posteo.de>
Reviewed-by: Oliver Bartsch <bo@cedev.de>
Reviewed-by: Benni Mack <benni@typo3.org>
Tested-by: core-ci <typo3@b13.com>
Tested-by: Daniel Goerz <daniel.goerz@posteo.de>
Tested-by: Oliver Bartsch <bo@cedev.de>
Tested-by: Benni Mack <benni@typo3.org>
  • Loading branch information
bmack committed Aug 9, 2021
1 parent 4bbbda7 commit 4a61e02
Showing 1 changed file with 28 additions and 22 deletions.
50 changes: 28 additions & 22 deletions typo3/sysext/filelist/Classes/FileList.php
Original file line number Diff line number Diff line change
Expand Up @@ -652,17 +652,19 @@ public function linkWrapFile($code, File $fileObject)
try {
if ($fileObject instanceof File && $fileObject->isIndexed() && $fileObject->checkActionPermission('editMeta') && $this->getBackendUser()->check('tables_modify', 'sys_file_metadata')) {
$metaData = $fileObject->getMetaData()->get();
$urlParameters = [
'edit' => [
'sys_file_metadata' => [
$metaData['uid'] => 'edit'
]
],
'returnUrl' => $this->listURL()
];
$url = (string)$this->uriBuilder->buildUriFromRoute('record_edit', $urlParameters);
$title = htmlspecialchars($this->getLanguageService()->sL('LLL:EXT:core/Resources/Private/Language/locallang_core.xlf:cm.editMetadata'));
$code = '<a class="responsive-title" href="' . htmlspecialchars($url) . '" title="' . $title . '">' . $code . '</a>';
if (!empty($metaData['uid'] ?? 0)) {
$urlParameters = [
'edit' => [
'sys_file_metadata' => [
$metaData['uid'] => 'edit'
]
],
'returnUrl' => $this->listURL()
];
$url = (string)$this->uriBuilder->buildUriFromRoute('record_edit', $urlParameters);
$title = htmlspecialchars($this->getLanguageService()->sL('LLL:EXT:core/Resources/Private/Language/locallang_core.xlf:cm.editMetadata'));
$code = '<a class="responsive-title" href="' . htmlspecialchars($url) . '" title="' . $title . '">' . $code . '</a>';
}
}
} catch (\Exception $e) {
// intentional fall-through
Expand Down Expand Up @@ -1017,17 +1019,21 @@ public function makeEdit($fileOrFolderObject)
// Edit metadata of file
if ($fileOrFolderObject instanceof File && $fileOrFolderObject->checkActionPermission('editMeta') && $this->getBackendUser()->check('tables_modify', 'sys_file_metadata')) {
$metaData = $fileOrFolderObject->getMetaData()->get();
$urlParameters = [
'edit' => [
'sys_file_metadata' => [
$metaData['uid'] => 'edit'
]
],
'returnUrl' => $this->listURL()
];
$url = (string)$this->uriBuilder->buildUriFromRoute('record_edit', $urlParameters);
$title = htmlspecialchars($this->getLanguageService()->sL('LLL:EXT:core/Resources/Private/Language/locallang_core.xlf:cm.editMetadata'));
$cells['metadata'] = '<a class="btn btn-default" href="' . htmlspecialchars($url) . '" title="' . $title . '">' . $this->iconFactory->getIcon('actions-open', Icon::SIZE_SMALL)->render() . '</a>';
if (!empty($metaData['uid'] ?? 0)) {
$urlParameters = [
'edit' => [
'sys_file_metadata' => [
$metaData['uid'] => 'edit'
]
],
'returnUrl' => $this->listURL()
];
$url = (string)$this->uriBuilder->buildUriFromRoute('record_edit', $urlParameters);
$title = htmlspecialchars($this->getLanguageService()->sL('LLL:EXT:core/Resources/Private/Language/locallang_core.xlf:cm.editMetadata'));
$cells['metadata'] = '<a class="btn btn-default" href="' . htmlspecialchars($url) . '" title="' . $title . '">' . $this->iconFactory->getIcon('actions-open', Icon::SIZE_SMALL)->render() . '</a>';
} else {
$cells['metadata'] = $this->spaceIcon;
}
}

// document view
Expand Down

0 comments on commit 4a61e02

Please sign in to comment.