Implement `Psr\Http\Message\ServerRequestInterface` in `wcf\system\request\Request`
authorTim Düsterhus <duesterhus@woltlab.com>
Thu, 19 May 2022 13:13:48 +0000 (15:13 +0200)
committerTim Düsterhus <duesterhus@woltlab.com>
Thu, 19 May 2022 13:13:48 +0000 (15:13 +0200)
wcfsetup/install/files/lib/system/request/Request.class.php
wcfsetup/install/files/lib/system/request/RequestHandler.class.php

index 74f5caad4db15a352ac5b759913b8f7eaaf6c169..7cc51e507fac9d2acde9f01fc732891e9835b290 100644 (file)
@@ -3,6 +3,8 @@
 namespace wcf\system\request;
 
 use Psr\Http\Message\ResponseInterface;
+use Psr\Http\Message\ServerRequestInterface;
+use Psr\Http\Server\RequestHandlerInterface;
 use wcf\data\page\PageCache;
 use wcf\http\LegacyPlaceholderResponse;
 
@@ -14,7 +16,7 @@ use wcf\http\LegacyPlaceholderResponse;
  * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
  * @package WoltLabSuite\Core\System\Request
  */
-final class Request
+final class Request implements RequestHandlerInterface
 {
     /**
      * page class name
@@ -82,21 +84,21 @@ final class Request
     }
 
     /**
-     * Executes this request.
+     * @inheritDoc
      */
-    public function execute(): ResponseInterface
+    public function handle(ServerRequestInterface $request): ResponseInterface
     {
         if ($this->requestObject === null) {
             $this->requestObject = new $this->className();
+        }
 
-            $response = $this->requestObject->__run();
-
-            if ($response instanceof ResponseInterface) {
-                return $response;
-            }
+        $response = $this->requestObject->__run();
 
-            return new LegacyPlaceholderResponse();
+        if ($response instanceof ResponseInterface) {
+            return $response;
         }
+
+        return new LegacyPlaceholderResponse();
     }
 
     /**
index 39c33a217611216ebb67ec1ccbe2d10cf2b38ed0..9cb4a6097658e62a6a3b94f8f98608084a847a8e 100644 (file)
@@ -3,6 +3,7 @@
 namespace wcf\system\request;
 
 use GuzzleHttp\Psr7\Header;
+use Laminas\Diactoros\ServerRequestFactory;
 use Laminas\HttpHandlerRunner\Emitter\SapiEmitter;
 use Psr\Http\Message\ResponseInterface;
 use wcf\http\LegacyPlaceholderResponse;
@@ -76,6 +77,8 @@ class RequestHandler extends SingletonFactory
                 }
             }
 
+            $psrRequest = ServerRequestFactory::fromGlobals();
+
             // build request
             $this->buildRequest($application);
 
@@ -101,7 +104,7 @@ class RequestHandler extends SingletonFactory
             }
 
             $this->sendPsr7Response(
-                $this->getActiveRequest()->execute()
+                $this->getActiveRequest()->handle($psrRequest)
             );
         } catch (NamedUserException $e) {
             $e->show();