From f06e99a078e1226bb4bc4753a20e13564058c234 Mon Sep 17 00:00:00 2001
From: Benni Mack <benni@typo3.org>
Date: Wed, 18 Oct 2017 23:02:19 +0200
Subject: [PATCH] [TASK] Move AjaxLoginHandler to AjaxLoginController

The AjaxLoginHandler which does AJAX logic for login timeouts is be moved
to the proper location, as it is a controller.

A class alias is in place.

Resolves: #82805
Releases: master
Change-Id: I6a9fed6236d6d82150dec2ac7c2ce61bd194b8ec
Reviewed-on: https://review.typo3.org/54441
Reviewed-by: Andreas Fernandez <typo3@scripting-base.de>
Tested-by: TYPO3com <no-reply@typo3.com>
Reviewed-by: Joerg Boesche <typo3@joergboesche.de>
Tested-by: Joerg Boesche <typo3@joergboesche.de>
Reviewed-by: Wouter Wolters <typo3@wouterwolters.nl>
Tested-by: Wouter Wolters <typo3@wouterwolters.nl>
---
 composer.json                                 |  1 +
 composer.lock                                 |  2 +-
 .../AjaxLoginController.php}                  |  4 +--
 .../Configuration/Backend/AjaxRoutes.php      |  8 ++---
 .../backend/Migrations/Code/ClassAliasMap.php |  4 +++
 .../Migrations/Code/LegacyClassesForIde.php   | 10 ++++++
 typo3/sysext/backend/composer.json            |  5 +++
 ...-82805-RenamedAjaxLoginHandlerPHPClass.rst | 34 +++++++++++++++++++
 .../ExtensionScanner/Php/ClassNameMatcher.php |  5 +++
 9 files changed, 66 insertions(+), 7 deletions(-)
 rename typo3/sysext/backend/Classes/{AjaxLoginHandler.php => Controller/AjaxLoginController.php} (98%)
 create mode 100644 typo3/sysext/backend/Migrations/Code/ClassAliasMap.php
 create mode 100644 typo3/sysext/backend/Migrations/Code/LegacyClassesForIde.php
 create mode 100644 typo3/sysext/core/Documentation/Changelog/master/Deprecation-82805-RenamedAjaxLoginHandlerPHPClass.rst

diff --git a/composer.json b/composer.json
index c7f27a03990f..d987be064963 100644
--- a/composer.json
+++ b/composer.json
@@ -70,6 +70,7 @@
 		"typo3/class-alias-loader": {
 			"always-add-alias-loader": true,
 			"class-alias-maps": [
+				"typo3/sysext/backend/Migrations/Code/ClassAliasMap.php",
 				"typo3/sysext/core/Migrations/Code/ClassAliasMap.php",
 				"typo3/sysext/documentation/Migrations/Code/ClassAliasMap.php",
 				"typo3/sysext/extbase/Migrations/Code/ClassAliasMap.php",
diff --git a/composer.lock b/composer.lock
index 3170386e9854..499465fd4d54 100644
--- a/composer.lock
+++ b/composer.lock
@@ -4,7 +4,7 @@
         "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file",
         "This file is @generated automatically"
     ],
-    "content-hash": "39981f9ff5c2b39ddf83a87ac8fc5d15",
+    "content-hash": "0e757db5e2ea6409800d3e505af4f744",
     "packages": [
         {
             "name": "cogpowered/finediff",
diff --git a/typo3/sysext/backend/Classes/AjaxLoginHandler.php b/typo3/sysext/backend/Classes/Controller/AjaxLoginController.php
similarity index 98%
rename from typo3/sysext/backend/Classes/AjaxLoginHandler.php
rename to typo3/sysext/backend/Classes/Controller/AjaxLoginController.php
index 46c0aca5d22d..6cddf7779878 100644
--- a/typo3/sysext/backend/Classes/AjaxLoginHandler.php
+++ b/typo3/sysext/backend/Classes/Controller/AjaxLoginController.php
@@ -1,5 +1,5 @@
 <?php
-namespace TYPO3\CMS\Backend;
+namespace TYPO3\CMS\Backend\Controller;
 
 /*
  * This file is part of the TYPO3 CMS project.
@@ -21,7 +21,7 @@ use TYPO3\CMS\Core\Authentication\BackendUserAuthentication;
 /**
  * This is the ajax handler for backend login after timeout.
  */
-class AjaxLoginHandler
+class AjaxLoginController
 {
     /**
      * Handles the actual login process, more specifically it defines the response.
diff --git a/typo3/sysext/backend/Configuration/Backend/AjaxRoutes.php b/typo3/sysext/backend/Configuration/Backend/AjaxRoutes.php
index 976f0b733a8b..cd6a6b4a5a11 100644
--- a/typo3/sysext/backend/Configuration/Backend/AjaxRoutes.php
+++ b/typo3/sysext/backend/Configuration/Backend/AjaxRoutes.php
@@ -122,27 +122,27 @@ return [
     // Log in into backend
     'login' => [
         'path' => '/login',
-        'target' => \TYPO3\CMS\Backend\AjaxLoginHandler::class . '::loginAction',
+        'target' => \TYPO3\CMS\Backend\Controller\AjaxLoginController::class . '::loginAction',
         'access' => 'public'
     ],
 
     // Log out from backend
     'logout' => [
         'path' => '/logout',
-        'target' => \TYPO3\CMS\Backend\AjaxLoginHandler::class . '::logoutAction',
+        'target' => \TYPO3\CMS\Backend\Controller\AjaxLoginController::class . '::logoutAction',
         'access' => 'public'
     ],
 
     // Refresh login of backend
     'login_refresh' => [
         'path' => '/login/refresh',
-        'target' => \TYPO3\CMS\Backend\AjaxLoginHandler::class . '::refreshAction',
+        'target' => \TYPO3\CMS\Backend\Controller\AjaxLoginController::class . '::refreshAction',
     ],
 
     // Check if backend session has timed out
     'login_timedout' => [
         'path' => '/login/timedout',
-        'target' => \TYPO3\CMS\Backend\AjaxLoginHandler::class . '::isTimedOutAction',
+        'target' => \TYPO3\CMS\Backend\Controller\AjaxLoginController::class . '::isTimedOutAction',
         'access' => 'public',
         'parameters' => [
             'skipSessionUpdate' => 1
diff --git a/typo3/sysext/backend/Migrations/Code/ClassAliasMap.php b/typo3/sysext/backend/Migrations/Code/ClassAliasMap.php
new file mode 100644
index 000000000000..f759d9c739b0
--- /dev/null
+++ b/typo3/sysext/backend/Migrations/Code/ClassAliasMap.php
@@ -0,0 +1,4 @@
+<?php
+return [
+    'TYPO3\\CMS\\Backend\\AjaxLoginHandler' => \TYPO3\CMS\Backend\Controller\AjaxLoginController::class,
+];
diff --git a/typo3/sysext/backend/Migrations/Code/LegacyClassesForIde.php b/typo3/sysext/backend/Migrations/Code/LegacyClassesForIde.php
new file mode 100644
index 000000000000..72f2dfeccd51
--- /dev/null
+++ b/typo3/sysext/backend/Migrations/Code/LegacyClassesForIde.php
@@ -0,0 +1,10 @@
+<?php
+namespace {
+    die('Access denied');
+}
+
+namespace TYPO3\CMS\Backend {
+    class AjaxLoginHandler extends \TYPO3\CMS\Backend\Controller\AjaxLoginController
+    {
+    }
+}
diff --git a/typo3/sysext/backend/composer.json b/typo3/sysext/backend/composer.json
index f516ceebdcf0..bee93bd8527a 100644
--- a/typo3/sysext/backend/composer.json
+++ b/typo3/sysext/backend/composer.json
@@ -30,6 +30,11 @@
 				"partOfMinimalUsableSystem": true
 			},
 			"extension-key": "backend"
+		},
+		"typo3/class-alias-loader": {
+			"class-alias-maps": [
+				"Migrations/Code/ClassAliasMap.php"
+			]
 		}
 	},
 	"autoload": {
diff --git a/typo3/sysext/core/Documentation/Changelog/master/Deprecation-82805-RenamedAjaxLoginHandlerPHPClass.rst b/typo3/sysext/core/Documentation/Changelog/master/Deprecation-82805-RenamedAjaxLoginHandlerPHPClass.rst
new file mode 100644
index 000000000000..568ee755d572
--- /dev/null
+++ b/typo3/sysext/core/Documentation/Changelog/master/Deprecation-82805-RenamedAjaxLoginHandlerPHPClass.rst
@@ -0,0 +1,34 @@
+.. include:: ../../Includes.txt
+
+========================================================
+Deprecation: #82805 - Renamed AjaxLoginHandler PHP class
+========================================================
+
+See :issue:`82805`
+
+Description
+===========
+
+The PHP class :php:`TYPO3\CMS\Backend\AjaxLoginHandler` is renamed to the proper class name
+:php:`TYPO3\CMS\Backend\Controller\AjaxLoginController` as its a controller class with actions.
+
+
+Impact
+======
+
+Using the old PHP class is possible but any usages should be moved to the new class name.
+
+
+Affected Installations
+======================
+
+Any TYPO3 instances using the PHP class directly in an extension.
+
+
+Migration
+=========
+
+A extension scanner already checks for the old class name. A simple renaming of the class name
+to the new class :php:`TYPO3\CMS\Backend\Controller\AjaxLoginController` is sufficient.
+
+.. index:: PHP-API, FullyScanned
\ No newline at end of file
diff --git a/typo3/sysext/install/Configuration/ExtensionScanner/Php/ClassNameMatcher.php b/typo3/sysext/install/Configuration/ExtensionScanner/Php/ClassNameMatcher.php
index 414ee5298b94..5b144b73983a 100644
--- a/typo3/sysext/install/Configuration/ExtensionScanner/Php/ClassNameMatcher.php
+++ b/typo3/sysext/install/Configuration/ExtensionScanner/Php/ClassNameMatcher.php
@@ -437,6 +437,11 @@ return [
             'Breaking-57594-OptimizeReflectionServiceCacheHandling.rst',
         ],
     ],
+    'TYPO3\CMS\Backend\AjaxLoginHandler' => [
+        'restFiles' => [
+            'Deprecation-82805-RenamedAjaxLoginHandlerPHPClass.rst',
+        ],
+    ],
 
     // Removed interfaces
     'TYPO3\CMS\Backend\Form\DatabaseFileIconsHookInterface' => [
-- 
GitLab