[BUGFIX] Use TCA to get `type` field instead of hardcoded fieldname 49/53749/8
authorSascha Egerer <sascha@sascha-egerer.de>
Mon, 21 Aug 2017 09:16:29 +0000 (11:16 +0200)
committerBenni Mack <benni@typo3.org>
Mon, 11 Sep 2017 17:02:31 +0000 (19:02 +0200)
The `type` field is configured via TCA and that configuration must
be used instead of hardcoding the fieldname.

Also change arrangement of the DataProvider load order to load
InitializeProcessedTca directly after ReturnUrl. This avoids the
need of accessing $GLOBALS['TCA'].

Resolves: #79954
Releases: master, 8.7
Change-Id: I67cbab00f6f0157c48c749cd8fbcd6cbc0ce1644
Reviewed-on: https://review.typo3.org/53749
Reviewed-by: Christian Kuhn <lolli@schwarzbu.ch>
Tested-by: Christian Kuhn <lolli@schwarzbu.ch>
Tested-by: TYPO3com <no-reply@typo3.com>
Reviewed-by: Benni Mack <benni@typo3.org>
Tested-by: Benni Mack <benni@typo3.org>
typo3/sysext/backend/Classes/Form/FormDataProvider/DatabaseUserPermissionCheck.php
typo3/sysext/backend/Tests/Unit/Form/FormDataProvider/DatabaseUserPermissionCheckTest.php
typo3/sysext/core/Configuration/DefaultConfiguration.php

index 5ccc050..27d6379 100644 (file)
@@ -115,7 +115,7 @@ class DatabaseUserPermissionCheck implements FormDataProviderInterface
             if ($result['tableName'] === 'pages') {
                 // A page record is edited, check edit rights of this record directly
                 $userPermissionOnPage = $backendUser->calcPerms($result['databaseRow']);
-                if ((bool)($userPermissionOnPage & Permission::PAGE_EDIT) && $backendUser->check('pagetypes_select', $result['databaseRow']['doktype'])) {
+                if ((bool)($userPermissionOnPage & Permission::PAGE_EDIT) && $backendUser->check('pagetypes_select', $result['databaseRow'][$result['processedTca']['ctrl']['type']])) {
                     $userHasAccess = true;
                 } else {
                     $exception = new AccessDeniedPageEditException(
index c8d7d81..9b82dcb 100644 (file)
@@ -164,6 +164,11 @@ class DatabaseUserPermissionCheckTest extends \TYPO3\TestingFramework\Core\Unit\
                 'pid' => 321,
                 'doktype' => 1,
             ],
+            'processedTca' => [
+                'ctrl' => [
+                    'type' => 'doktype'
+                ]
+            ]
         ];
         $this->beUserProphecy->isAdmin()->willReturn(false);
         $this->beUserProphecy->check('tables_modify', $input['tableName'])->willReturn(true);
@@ -191,6 +196,11 @@ class DatabaseUserPermissionCheckTest extends \TYPO3\TestingFramework\Core\Unit\
                 'pid' => 321,
                 'doktype' => 1,
             ],
+            'processedTca' => [
+                'ctrl' => [
+                    'type' => 'doktype'
+                ]
+            ]
         ];
         $this->beUserProphecy->isAdmin()->willReturn(false);
         $this->beUserProphecy->check('tables_modify', $input['tableName'])->willReturn(true);
index 951d1a2..37eae4f 100644 (file)
@@ -312,9 +312,14 @@ return [
             'formDataGroup' => [ // Array: Registry of form data providers for form data groups
                 'tcaDatabaseRecord' => [
                     \TYPO3\CMS\Backend\Form\FormDataProvider\ReturnUrl::class => [],
-                    \TYPO3\CMS\Backend\Form\FormDataProvider\DatabaseEditRow::class => [
+                    \TYPO3\CMS\Backend\Form\FormDataProvider\InitializeProcessedTca::class => [
                         'depends' => [
                             \TYPO3\CMS\Backend\Form\FormDataProvider\ReturnUrl::class,
+                        ],
+                    ],
+                    \TYPO3\CMS\Backend\Form\FormDataProvider\DatabaseEditRow::class => [
+                        'depends' => [
+                            \TYPO3\CMS\Backend\Form\FormDataProvider\InitializeProcessedTca::class,
                         ]
                     ],
                     \TYPO3\CMS\Backend\Form\FormDataProvider\DatabaseParentPageRow::class => [
@@ -325,6 +330,7 @@ return [
                     \TYPO3\CMS\Backend\Form\FormDataProvider\DatabaseUserPermissionCheck::class => [
                         'depends' => [
                             \TYPO3\CMS\Backend\Form\FormDataProvider\DatabaseParentPageRow::class,
+                            \TYPO3\CMS\Backend\Form\FormDataProvider\InitializeProcessedTca::class,
                         ],
                     ],
                     \TYPO3\CMS\Backend\Form\FormDataProvider\DatabaseEffectivePid::class => [
@@ -349,14 +355,9 @@ return [
                             \TYPO3\CMS\Backend\Form\FormDataProvider\UserTsConfig::class
                         ],
                     ],
-                    \TYPO3\CMS\Backend\Form\FormDataProvider\InitializeProcessedTca::class => [
-                        'depends' => [
-                            \TYPO3\CMS\Backend\Form\FormDataProvider\PageTsConfig::class,
-                        ],
-                    ],
                     \TYPO3\CMS\Backend\Form\FormDataProvider\InlineOverrideChildTca::class => [
                         'depends' => [
-                            \TYPO3\CMS\Backend\Form\FormDataProvider\InitializeProcessedTca::class,
+                            \TYPO3\CMS\Backend\Form\FormDataProvider\PageTsConfig::class,
                         ],
                     ],
                     \TYPO3\CMS\Backend\Form\FormDataProvider\ParentPageTca::class => [
@@ -572,11 +573,16 @@ return [
                             \TYPO3\CMS\Backend\Form\FormDataProvider\DatabaseEditRow::class,
                         ],
                     ],
-                    \TYPO3\CMS\Backend\Form\FormDataProvider\DatabaseUserPermissionCheck::class => [
+                    \TYPO3\CMS\Backend\Form\FormDataProvider\InitializeProcessedTca::class => [
                         'depends' => [
                             \TYPO3\CMS\Backend\Form\FormDataProvider\DatabaseParentPageRow::class,
                         ],
                     ],
+                    \TYPO3\CMS\Backend\Form\FormDataProvider\DatabaseUserPermissionCheck::class => [
+                        'depends' => [
+                            \TYPO3\CMS\Backend\Form\FormDataProvider\InitializeProcessedTca::class,
+                        ],
+                    ],
                     \TYPO3\CMS\Backend\Form\FormDataProvider\DatabaseEffectivePid::class => [
                         'depends' => [
                             \TYPO3\CMS\Backend\Form\FormDataProvider\DatabaseParentPageRow::class,