From: Tim Düsterhus Date: Thu, 19 May 2022 13:13:48 +0000 (+0200) Subject: Implement `Psr\Http\Message\ServerRequestInterface` in `wcf\system\request\Request` X-Git-Tag: 6.0.0_Alpha_1~1266^2~11 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=8b2e25127df502c118dfab94c307344ff7777a8d;p=GitHub%2FWoltLab%2FWCF.git Implement `Psr\Http\Message\ServerRequestInterface` in `wcf\system\request\Request` --- diff --git a/wcfsetup/install/files/lib/system/request/Request.class.php b/wcfsetup/install/files/lib/system/request/Request.class.php index 74f5caad4d..7cc51e507f 100644 --- a/wcfsetup/install/files/lib/system/request/Request.class.php +++ b/wcfsetup/install/files/lib/system/request/Request.class.php @@ -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 * @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(); } /** diff --git a/wcfsetup/install/files/lib/system/request/RequestHandler.class.php b/wcfsetup/install/files/lib/system/request/RequestHandler.class.php index 39c33a2176..9cb4a60976 100644 --- a/wcfsetup/install/files/lib/system/request/RequestHandler.class.php +++ b/wcfsetup/install/files/lib/system/request/RequestHandler.class.php @@ -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();