From bf6ee546a0496b0707b7546d40bf07b389b5139d Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=C5=81ukasz=20Uzna=C5=84ski?= <l.uznanski@macopedia.pl>
Date: Mon, 27 Nov 2017 11:15:00 +0100
Subject: [PATCH] [BUGFIX] Disable edit of file metadata without translation

This avoids an error in case file metadata is edited through a file
reference and there is no file metadata translation for the current
language.

Resolves: #76262
Resolves: #82178
Releases: master, 8.7
Change-Id: Ifecf659637773c5f3773fc3439b09df9c030cb3f
Reviewed-on: https://review.typo3.org/54778
Tested-by: TYPO3com <no-reply@typo3.com>
Reviewed-by: Susanne Moog <susanne.moog@typo3.org>
Tested-by: Susanne Moog <susanne.moog@typo3.org>
Reviewed-by: Christian Kuhn <lolli@schwarzbu.ch>
Tested-by: Christian Kuhn <lolli@schwarzbu.ch>
---
 .../backend/Classes/Form/Container/InlineRecordContainer.php  | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/typo3/sysext/backend/Classes/Form/Container/InlineRecordContainer.php b/typo3/sysext/backend/Classes/Form/Container/InlineRecordContainer.php
index e7cafdb263b7..d00ac33f581f 100644
--- a/typo3/sysext/backend/Classes/Form/Container/InlineRecordContainer.php
+++ b/typo3/sysext/backend/Classes/Form/Container/InlineRecordContainer.php
@@ -495,7 +495,7 @@ class InlineRecordContainer extends AbstractContainer
                     </a>';
             }
             // "Edit" link:
-            if (($rec['table_local'] === 'sys_file') && !$isNewItem) {
+            if (($rec['table_local'] === 'sys_file') && !$isNewItem && $backendUser->check('tables_modify', 'sys_file_metadata')) {
                 $sys_language_uid = 0;
                 if (!empty($rec['sys_language_uid'])) {
                     $sys_language_uid = $rec['sys_language_uid'][0];
@@ -518,7 +518,7 @@ class InlineRecordContainer extends AbstractContainer
                     ->setMaxResults(1)
                     ->execute()
                     ->fetch();
-                if ($backendUser->check('tables_modify', 'sys_file_metadata')) {
+                if (!empty($recordInDatabase)) {
                     $url = BackendUtility::getModuleUrl('record_edit', [
                         'edit[sys_file_metadata][' . (int)$recordInDatabase['uid'] . ']' => 'edit',
                         'returnUrl' => $this->data['returnUrl']
-- 
GitLab