[TASK] Use PSR-15 RequestHandler in Install Tool 69/58469/3
authorBenni Mack <benni@typo3.org>
Sat, 29 Sep 2018 18:13:30 +0000 (20:13 +0200)
committerGeorg Ringer <georg.ringer@gmail.com>
Sat, 29 Sep 2018 18:48:58 +0000 (20:48 +0200)
Install Tool still uses TYPO3's own RequestHandler interface which
exists since TYPO3 v7, but is superseded with PSR-15's
RequestHandler concept.

Install Tool now uses PSR-15 and the old interface in order
to still use the priority concept.

In a further step, both RequestHandlers should be migrated to
Middleware+RequestHandler concept.

Resolves: #86451
Releases: master
Change-Id: I55cf31a2b803951491ba072969a4cff68ef2c2ac
Reviewed-on: https://review.typo3.org/58469
Reviewed-by: Georg Ringer <georg.ringer@gmail.com>
Tested-by: Georg Ringer <georg.ringer@gmail.com>
typo3/sysext/core/Classes/Http/RequestHandlerInterface.php
typo3/sysext/install/Classes/Http/Application.php
typo3/sysext/install/Classes/Http/InstallerRequestHandler.php
typo3/sysext/install/Classes/Http/RequestHandler.php

index 185aec5..137154e 100644 (file)
@@ -22,7 +22,7 @@ use Psr\Http\Message\ServerRequestInterface;
  * The interface for a request handler
  * see RequestHandler in EXT:backend/Classes/Http/ and EXT:frontend/Classes/Http
  *
- * @api
+ * @internal although TYPO3 Core still uses this in TYPO3 v9, this will be removed with PSR-15 RequestHandlerInterface
  */
 interface RequestHandlerInterface
 {
index 5ba6e3e..8038428 100644 (file)
@@ -61,7 +61,7 @@ class Application extends AbstractApplication
         $this->initializeContext();
         foreach ($this->availableRequestHandlers as $handler) {
             if ($handler->canHandleRequest($request)) {
-                return $handler->handleRequest($request);
+                return $handler->handle($request);
             }
         }
         throw new \TYPO3\CMS\Core\Exception('No suitable request handler found.', 1518448686);
index f503676..cb65ec9 100644 (file)
@@ -17,6 +17,7 @@ namespace TYPO3\CMS\Install\Http;
 
 use Psr\Http\Message\ResponseInterface;
 use Psr\Http\Message\ServerRequestInterface;
+use Psr\Http\Server\RequestHandlerInterface as PsrRequestHandlerInterface;
 use TYPO3\CMS\Core\Configuration\ConfigurationManager;
 use TYPO3\CMS\Core\FormProtection\FormProtectionFactory;
 use TYPO3\CMS\Core\FormProtection\InstallToolFormProtection;
@@ -29,10 +30,10 @@ use TYPO3\CMS\Install\Service\SessionService;
 /**
  * Request handler to walk through the web installation process of TYPO3
  */
-class InstallerRequestHandler implements RequestHandlerInterface
+class InstallerRequestHandler implements RequestHandlerInterface, PsrRequestHandlerInterface
 {
     /**
-     * Handles an install tool request when nothing is there
+     * Handles an Install Tool request when nothing is there
      *
      * @param ServerRequestInterface $request
      * @return ResponseInterface
@@ -40,6 +41,18 @@ class InstallerRequestHandler implements RequestHandlerInterface
      */
     public function handleRequest(ServerRequestInterface $request): ResponseInterface
     {
+        return $this->handle($request);
+    }
+
+    /**
+     * Handles an Install Tool request when nothing is there
+     *
+     * @param ServerRequestInterface $request
+     * @return ResponseInterface
+     * @throws \RuntimeException
+     */
+    public function handle(ServerRequestInterface $request): ResponseInterface
+    {
         $controller = new InstallerController();
         $actionName = $request->getParsedBody()['install']['action'] ?? $request->getQueryParams()['install']['action'] ?? 'init';
         $action = $actionName . 'Action';
index f2a6f3e..86429f4 100644 (file)
@@ -17,6 +17,7 @@ namespace TYPO3\CMS\Install\Http;
 
 use Psr\Http\Message\ResponseInterface;
 use Psr\Http\Message\ServerRequestInterface;
+use Psr\Http\Server\RequestHandlerInterface as PsrRequestHandlerInterface;
 use TYPO3\CMS\Core\Configuration\ConfigurationManager;
 use TYPO3\CMS\Core\Core\Environment;
 use TYPO3\CMS\Core\Crypto\PasswordHashing\PasswordHashFactory;
@@ -46,7 +47,7 @@ use TYPO3\CMS\Install\Service\SessionService;
  * Default request handler for all requests inside the TYPO3 Install Tool, which does a simple hardcoded
  * dispatching to a controller based on the get/post variable.
  */
-class RequestHandler implements RequestHandlerInterface
+class RequestHandler implements RequestHandlerInterface, PsrRequestHandlerInterface
 {
     /**
      * @var ConfigurationManager
@@ -75,13 +76,24 @@ class RequestHandler implements RequestHandlerInterface
     }
 
     /**
-     * Handles an install tool request for normal operations
+     * Handles an Install Tool request for normal operations
      *
      * @param ServerRequestInterface $request
      * @return ResponseInterface
      */
     public function handleRequest(ServerRequestInterface $request): ResponseInterface
     {
+        return $this->handle($request);
+    }
+
+    /**
+     * Handles an Install Tool request for normal operations
+     *
+     * @param ServerRequestInterface $request
+     * @return ResponseInterface
+     */
+    public function handle(ServerRequestInterface $request): ResponseInterface
+    {
         $controllerName = $request->getQueryParams()['install']['controller'] ?? 'layout';
         $actionName = $request->getParsedBody()['install']['action'] ?? $request->getQueryParams()['install']['action'] ?? 'init';
         $action = $actionName . 'Action';