[BUGFIX] Access module uses DataHandler for updating page 30/62930/3
authorBenni Mack <benni@typo3.org>
Thu, 16 Jan 2020 12:28:06 +0000 (13:28 +0100)
committerDaniel Goerz <daniel.goerz@posteo.de>
Thu, 16 Jan 2020 13:29:20 +0000 (14:29 +0100)
The permission access module allows for AJAX calls to dynamically
updating page permissions on the fly, where DataHandler is used.

When using the form to do a more customizable change,
plain SQL was used previously to update the pages. This circumvented
the change to also update any translated pages (which DataHandler does
by default).

This wasn't a problem until TYPO3 v9.0, where pages_language_overlay
was merged with "pages", where the permissions of translated pages
should reflect the changes of the default language page.

The change updates the PermissionController->updateAction
to call DataHandler for the changes as well.

Resolves: #89838
Resolves: #88311
Releases: master, 9.5
Change-Id: I9e56b279ddcbb43ee7bb11b330c288b12a0e7439
Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/62930
Tested-by: TYPO3com <noreply@typo3.com>
Tested-by: Susanne Moog <look@susi.dev>
Tested-by: Jörg Bösche <typo3@joergboesche.de>
Tested-by: Daniel Goerz <daniel.goerz@posteo.de>
Reviewed-by: Susanne Moog <look@susi.dev>
Reviewed-by: Jörg Bösche <typo3@joergboesche.de>
Reviewed-by: Daniel Goerz <daniel.goerz@posteo.de>
typo3/sysext/beuser/Classes/Controller/PermissionController.php

index 2d015dd..48a1e31 100644 (file)
@@ -18,7 +18,7 @@ use TYPO3\CMS\Backend\Template\Components\ButtonBar;
 use TYPO3\CMS\Backend\Tree\View\PageTreeView;
 use TYPO3\CMS\Backend\Utility\BackendUtility;
 use TYPO3\CMS\Backend\View\BackendTemplateView;
-use TYPO3\CMS\Core\Database\ConnectionPool;
+use TYPO3\CMS\Core\DataHandling\DataHandler;
 use TYPO3\CMS\Core\Imaging\Icon;
 use TYPO3\CMS\Core\Messaging\FlashMessage;
 use TYPO3\CMS\Core\Utility\GeneralUtility;
@@ -313,6 +313,8 @@ class PermissionController extends ActionController
      */
     protected function updateAction(array $data, array $mirror)
     {
+        $dataHandlerInput = [];
+        // Prepare the input data for data handler
         if (!empty($data['pages'])) {
             foreach ($data['pages'] as $pageUid => $properties) {
                 // if the owner and group field shouldn't be touched, unset the option
@@ -322,25 +324,25 @@ class PermissionController extends ActionController
                 if ((int)$properties['perms_groupid'] === -1) {
                     unset($properties['perms_groupid']);
                 }
-                $connection = GeneralUtility::makeInstance(ConnectionPool::class)->getConnectionForTable('pages');
-                $connection->update(
-                    'pages',
-                    $properties,
-                    ['uid' => (int)$pageUid]
-                );
-
+                $dataHandlerInput[$pageUid] = $properties;
                 if (!empty($mirror['pages'][$pageUid])) {
-                    $mirrorPages = GeneralUtility::trimExplode(',', $mirror['pages'][$pageUid]);
+                    $mirrorPages = GeneralUtility::intExplode(',', $mirror['pages'][$pageUid]);
                     foreach ($mirrorPages as $mirrorPageUid) {
-                        $connection->update(
-                            'pages',
-                            $properties,
-                            ['uid' => (int)$mirrorPageUid]
-                        );
+                        $dataHandlerInput[$mirrorPageUid] = $properties;
                     }
                 }
             }
         }
+
+        $dataHandler = GeneralUtility::makeInstance(DataHandler::class);
+        $dataHandler->start(
+            [
+                'pages' => $dataHandlerInput
+            ],
+            []
+        );
+        $dataHandler->process_datamap();
+
         $this->redirectToUri($this->returnUrl);
     }