From 4aaceb5aaacab72b055bb82166412ae6ff580ff1 Mon Sep 17 00:00:00 2001
From: Michael Oehlhof <typo3@oehlhof.de>
Date: Thu, 15 Oct 2015 00:10:50 +0200
Subject: [PATCH] [BUGFIX] Fix fatal error in PermissionController

Make sure we deal with the correct view class before accessing
any members of it.

Resolves: #70728
Releases: master
Change-Id: I0cd8c2d775f7c0fd7202b314f1fc3ce3c71b58dc
Reviewed-on: http://review.typo3.org/44070
Reviewed-by: Michael Oehlhof <typo3@oehlhof.de>
Tested-by: Michael Oehlhof <typo3@oehlhof.de>
Reviewed-by: Marcus Schwemer <ms@schwemer.de>
Tested-by: Marcus Schwemer <ms@schwemer.de>
Reviewed-by: Markus Klein <markus.klein@typo3.org>
Tested-by: Markus Klein <markus.klein@typo3.org>
---
 .../Controller/PermissionController.php       | 29 ++++++++++---------
 1 file changed, 16 insertions(+), 13 deletions(-)

diff --git a/typo3/sysext/beuser/Classes/Controller/PermissionController.php b/typo3/sysext/beuser/Classes/Controller/PermissionController.php
index 0414d83a2ab5..e01603f23ca8 100644
--- a/typo3/sysext/beuser/Classes/Controller/PermissionController.php
+++ b/typo3/sysext/beuser/Classes/Controller/PermissionController.php
@@ -116,7 +116,6 @@ class PermissionController extends ActionController
      */
     protected function initializeView(ViewInterface $view)
     {
-        /** @var BackendTemplateView $view */
         parent::initializeView($view);
         $view->assign(
             'previewUrl',
@@ -125,17 +124,21 @@ class PermissionController extends ActionController
                 BackendUtility::BEgetRootLine($this->pageInfo['uid'])
             )
         );
-        $this->view->getModuleTemplate()->getPageRenderer()->loadRequireJsModule('TYPO3/CMS/Beuser/Permissions');
-        $this->view->getModuleTemplate()->addJavaScriptCode(
-            'jumpToUrl',
-            '
-            function jumpToUrl(URL) {
-                window.location.href = URL;
-                return false;
-            }
-            '
-        );
-        $this->registerDocheaderButtons();
+
+        // the view of the update action has a different view class
+        if ($view instanceof BackendTemplateView) {
+            $view->getModuleTemplate()->getPageRenderer()->loadRequireJsModule('TYPO3/CMS/Beuser/Permissions');
+            $view->getModuleTemplate()->addJavaScriptCode(
+                'jumpToUrl',
+                '
+                function jumpToUrl(URL) {
+                    window.location.href = URL;
+                    return false;
+                }
+                '
+            );
+            $this->registerDocHeaderButtons();
+        }
     }
 
     /**
@@ -144,7 +147,7 @@ class PermissionController extends ActionController
      * @return void
      * @throws \InvalidArgumentException
      */
-    protected function registerDocheaderButtons()
+    protected function registerDocHeaderButtons()
     {
         /** @var ButtonBar $buttonBar */
         $buttonBar = $this->view->getModuleTemplate()->getDocHeaderComponent()->getButtonBar();
-- 
GitLab