From 3a60e6ae47c9f8968c1f8a5985951e0e11af93f7 Mon Sep 17 00:00:00 2001
From: Benni Mack <benni@typo3.org>
Date: Mon, 27 Mar 2017 18:15:26 +0200
Subject: [PATCH] [BUGFIX] Extbase should not use deprecated CLI admin role
 methods

Resolves: #80492
Releases: master
Change-Id: Id835329586bf0fa315dc46377bc195ace005da61
Reviewed-on: https://review.typo3.org/52188
Tested-by: TYPO3com <no-reply@typo3.com>
Reviewed-by: Andreas Fernandez <typo3@scripting-base.de>
Tested-by: Mona Muzaffar <mona.muzaffar@gmx.de>
Reviewed-by: Christian Kuhn <lolli@schwarzbu.ch>
Tested-by: Christian Kuhn <lolli@schwarzbu.ch>
---
 .../Mvc/Controller/CommandController.php      |  2 --
 .../Mvc/Controller/CommandControllerTest.php  | 26 -------------------
 2 files changed, 28 deletions(-)

diff --git a/typo3/sysext/extbase/Classes/Mvc/Controller/CommandController.php b/typo3/sysext/extbase/Classes/Mvc/Controller/CommandController.php
index 741debf70f3d..4c286f8d7c8d 100644
--- a/typo3/sysext/extbase/Classes/Mvc/Controller/CommandController.php
+++ b/typo3/sysext/extbase/Classes/Mvc/Controller/CommandController.php
@@ -249,9 +249,7 @@ class CommandController implements CommandControllerInterface
         foreach ($this->arguments as $argument) {
             $preparedArguments[] = $argument->getValue();
         }
-        $originalRole = $this->ensureAdminRoleIfRequested();
         $commandResult = call_user_func_array([$this, $this->commandMethodName], $preparedArguments);
-        $this->restoreUserRole($originalRole);
         if (is_string($commandResult) && $commandResult !== '') {
             $this->response->appendContent($commandResult);
         } elseif (is_object($commandResult) && method_exists($commandResult, '__toString')) {
diff --git a/typo3/sysext/extbase/Tests/Unit/Mvc/Controller/CommandControllerTest.php b/typo3/sysext/extbase/Tests/Unit/Mvc/Controller/CommandControllerTest.php
index 94788ad1144e..0923e85e0cb6 100644
--- a/typo3/sysext/extbase/Tests/Unit/Mvc/Controller/CommandControllerTest.php
+++ b/typo3/sysext/extbase/Tests/Unit/Mvc/Controller/CommandControllerTest.php
@@ -79,30 +79,4 @@ class CommandControllerTest extends \TYPO3\TestingFramework\Core\Unit\UnitTestCa
         $this->commandController->_set('response', $mockResponse);
         $this->commandController->_call('quit', 123);
     }
-
-    /**
-     * @test
-     */
-    public function settingRequestAdminPropertySetsAdminRoleInUserAuthentication()
-    {
-        $mockedUserAuthentication = $this->createMock(\TYPO3\CMS\Core\Authentication\AbstractUserAuthentication::class);
-        $mockedUserAuthentication->user['admin'] = 42;
-        $this->commandController->expects($this->once())
-            ->method('dummyCommand')
-            ->will(
-                $this->returnCallback(
-                    function () use ($mockedUserAuthentication) {
-                        if ($mockedUserAuthentication->user['admin'] !== 1) {
-                            throw new \Exception('User role is not admin', 1476050222);
-                        }
-                    }
-                ));
-        $GLOBALS['BE_USER'] = $mockedUserAuthentication;
-        $this->commandController->_set('arguments', []);
-        $this->commandController->_set('commandMethodName', 'dummyCommand');
-        $this->commandController->_set('requestAdminPermissions', true);
-        $this->commandController->_call('callCommandMethod');
-
-        $this->assertSame(42, $mockedUserAuthentication->user['admin']);
-    }
 }
-- 
GitLab