[TASK] Use ServerRequestInterface in LogoutController 64/56164/9
authorŁukasz Uznański <l.uznanski@macopedia.pl>
Thu, 15 Mar 2018 13:24:04 +0000 (14:24 +0100)
committerChristian Kuhn <lolli@schwarzbu.ch>
Thu, 15 Mar 2018 17:36:03 +0000 (18:36 +0100)
Set public methods deprecated, replace them by protected
methods and use them in class, set declare strict types.

Resolves: #84275
Releases: master
Change-Id: I4351a3a422347d643353b41188f07a6965e5e92a
Reviewed-on: https://review.typo3.org/56164
Reviewed-by: Mathias Brodala <mbrodala@pagemachine.de>
Tested-by: Mathias Brodala <mbrodala@pagemachine.de>
Tested-by: TYPO3com <no-reply@typo3.com>
Reviewed-by: Christian Kuhn <lolli@schwarzbu.ch>
Tested-by: Christian Kuhn <lolli@schwarzbu.ch>
typo3/sysext/backend/Classes/Controller/LogoutController.php
typo3/sysext/core/Documentation/Changelog/master/Deprecation-84275-ProtectedMethodInLogoutController.rst [new file with mode: 0644]
typo3/sysext/install/Configuration/ExtensionScanner/Php/MethodCallMatcher.php

index b4fe925..62d9a22 100644 (file)
@@ -1,4 +1,5 @@
 <?php
+declare(strict_types = 1);
 namespace TYPO3\CMS\Backend\Controller;
 
 /*
@@ -37,7 +38,7 @@ class LogoutController
      */
     public function logoutAction(ServerRequestInterface $request): ResponseInterface
     {
-        $this->logout();
+        $this->processLogout();
 
         $redirectUrl = $request->getParsedBody()['redirect'] ?? $request->getQueryParams()['redirect'];
         $redirectUrl = GeneralUtility::sanitizeLocalUrl($redirectUrl);
@@ -50,9 +51,20 @@ class LogoutController
 
     /**
      * Performs the logout processing
+     *
+     * @deprecated since v9, will be removed in v10
      */
     public function logout()
     {
+        trigger_error('Method logout() will be replaced by protected method processLogout() in v10. Do not call from other extension', E_USER_DEPRECATED);
+        $this->processLogout();
+    }
+
+    /**
+     * Performs the logout processing
+     */
+    protected function processLogout(): void
+    {
         if (empty($this->getBackendUser()->user['username'])) {
             return;
         }
diff --git a/typo3/sysext/core/Documentation/Changelog/master/Deprecation-84275-ProtectedMethodInLogoutController.rst b/typo3/sysext/core/Documentation/Changelog/master/Deprecation-84275-ProtectedMethodInLogoutController.rst
new file mode 100644 (file)
index 0000000..35a5ccd
--- /dev/null
@@ -0,0 +1,42 @@
+.. include:: ../../Includes.txt
+
+==========================================================================
+Deprecation: #84275 - Protected methods and properties in LogoutController
+==========================================================================
+
+See :issue:`84275`
+
+Description
+===========
+
+This file is about third party usage (consumer that call the class as well as
+signals or hooks depending on it) of :php:`TYPO3\CMS\Backend\Controller\LogoutController`.
+
+All methods not used as entry points by :php:`TYPO3\CMS\Backend\Http\RouteDispatcher` will be
+removed or set to protected in v10 and throw deprecation warnings if used from a third party:
+
+* :php:`logout()`
+
+
+Impact
+======
+
+Calling above method on an instance of
+:php:`LogoutController` will throw a deprecation warning in v9 and a PHP fatal in v10.
+
+
+Affected Installations
+======================
+
+The extension scanner will find all usages, but may also find some false positives.
+In general all extensions that call :php:`logout()` are affected.
+
+
+Migration
+=========
+
+In general, extensions should not instantiate and re-use controllers of the core. Existing
+usages should be rewritten to be free of calls like these.
+
+
+.. index:: Backend, PHP-API, FullyScanned
\ No newline at end of file
index ad9f50f..b9730ef 100644 (file)
@@ -1913,4 +1913,11 @@ return [
             'Deprecation-84273-ProtectedMethodsAndPropertiesInFileSystemNavigationFrameController.rst',
         ],
     ],
+    'TYPO3\CMS\Backend\Controller\LogoutController->logout' => [
+        'numberOfMandatoryArguments' => 0,
+        'maximumNumberOfArguments' => 0,
+        'restFiles' => [
+            'Deprecation-84275-ProtectedMethodInLogoutController.rst',
+        ],
+    ],
 ];