From 3607634b48ce818415bc16f19c63145def83bf0c Mon Sep 17 00:00:00 2001
From: Oliver Bartsch <bo@cedev.de>
Date: Fri, 2 Oct 2020 12:22:33 +0200
Subject: [PATCH] [BUGFIX] Use correct page id for permission calculation of
 inline controls

For the inline record header controls the InlineRecordContainer calculates
the permissions for the page, the record is on. Previously the calculation
was based on the records pid. This does not work for new records as the
pid is a negative integer in this case - uid of the record the `new` button
was pressed on - and therefore led to no header controls were displayed
till the record was saved.

The calculation now uses the correct uid from `parentPageRow`.

Resolves: #84867
Releases: master, 10.4
Change-Id: I3d60f41ed51ff2f013d37c6aa9c118974d06acad
Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/65999
Tested-by: TYPO3com <noreply@typo3.com>
Tested-by: Christian Kuhn <lolli@schwarzbu.ch>
Tested-by: Anja Leichsenring <aleichsenring@ab-softlab.de>
Reviewed-by: Christian Kuhn <lolli@schwarzbu.ch>
Reviewed-by: Oliver Klee <typo3-coding@oliverklee.de>
Reviewed-by: Anja Leichsenring <aleichsenring@ab-softlab.de>
---
 .../backend/Classes/Form/Container/InlineRecordContainer.php    | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/typo3/sysext/backend/Classes/Form/Container/InlineRecordContainer.php b/typo3/sysext/backend/Classes/Form/Container/InlineRecordContainer.php
index 2d2702cbbded..3d657dbe462d 100644
--- a/typo3/sysext/backend/Classes/Form/Container/InlineRecordContainer.php
+++ b/typo3/sysext/backend/Classes/Form/Container/InlineRecordContainer.php
@@ -445,7 +445,7 @@ class InlineRecordContainer extends AbstractContainer
         $isSysFileReferenceTable = $foreignTable === 'sys_file_reference';
         $enableManualSorting = $tcaTableCtrl['sortby'] || $inlineConfig['MM'] || !$data['isOnSymmetricSide']
             && $inlineConfig['foreign_sortby'] || $data['isOnSymmetricSide'] && $inlineConfig['symmetric_sortby'];
-        $calcPerms = new Permission($backendUser->calcPerms(BackendUtility::readPageAccess($rec['pid'], $backendUser->getPagePermsClause(Permission::PAGE_SHOW))));
+        $calcPerms = new Permission($backendUser->calcPerms(BackendUtility::readPageAccess((int)($data['parentPageRow']['uid'] ?? 0), $backendUser->getPagePermsClause(Permission::PAGE_SHOW))));
         // If the listed table is 'pages' we have to request the permission settings for each page:
         $localCalcPerms = new Permission(Permission::NOTHING);
         if ($isPagesTable) {
-- 
GitLab