diff --git a/typo3/sysext/backend/Classes/Console/Application.php b/typo3/sysext/backend/Classes/Console/Application.php index bca462ee6102216a5fa19b1b487fd781c4f2988c..26868fb63b398b05a3a52dad7545329a09e71196 100644 --- a/typo3/sysext/backend/Classes/Console/Application.php +++ b/typo3/sysext/backend/Classes/Console/Application.php @@ -58,6 +58,8 @@ class Application implements ApplicationInterface { foreach ($this->availableRequestHandlers as $requestHandler) { $this->bootstrap->registerRequestHandlerImplementation($requestHandler); } + + $this->bootstrap->configure(); } /** @@ -67,7 +69,7 @@ class Application implements ApplicationInterface { * @return void */ public function run(callable $execute = NULL) { - $this->bootstrap->run(); + $this->bootstrap->handleRequest(new \Symfony\Component\Console\Input\ArgvInput()); if ($execute !== NULL) { if ($execute instanceof \Closure) { diff --git a/typo3/sysext/backend/Classes/Console/CliRequestHandler.php b/typo3/sysext/backend/Classes/Console/CliRequestHandler.php index 3e9c24f3f2606f303cb7bea8c79bea86227af732..6b6119538b160b5c96eda516918c8caddea894a3 100644 --- a/typo3/sysext/backend/Classes/Console/CliRequestHandler.php +++ b/typo3/sysext/backend/Classes/Console/CliRequestHandler.php @@ -14,9 +14,8 @@ namespace TYPO3\CMS\Backend\Console; * The TYPO3 project - inspiring people to share! */ -use Psr\Http\Message\ServerRequestInterface; use TYPO3\CMS\Core\Core\Bootstrap; -use TYPO3\CMS\Core\Core\RequestHandlerInterface; +use TYPO3\CMS\Core\Console\RequestHandlerInterface; use TYPO3\CMS\Core\Utility\GeneralUtility; /** @@ -45,10 +44,10 @@ class CliRequestHandler implements RequestHandlerInterface { /** * Handles any commandline request * - * @param ServerRequestInterface $request + * @param \Symfony\Component\Console\Input\InputInterface $request * @return void */ - public function handleRequest(ServerRequestInterface $request) { + public function handleRequest(\Symfony\Component\Console\Input\InputInterface $request) { $commandLineKey = $this->getCommandLineKeyOrDie(); $commandLineScript = $this->getIncludeScriptByCommandLineKey($commandLineKey); @@ -137,12 +136,12 @@ class CliRequestHandler implements RequestHandlerInterface { } /** - * This request handler can handle any CLI request . + * This request handler can handle any CLI request. * - * @param ServerRequestInterface $request + * @param \Symfony\Component\Console\Input\InputInterface $request * @return bool If the request is a CLI request, TRUE otherwise FALSE */ - public function canHandleRequest(ServerRequestInterface $request) { + public function canHandleRequest(\Symfony\Component\Console\Input\InputInterface $request) { return defined('TYPO3_cliMode') && (TYPO3_REQUESTTYPE & TYPO3_REQUESTTYPE_BE) && (TYPO3_REQUESTTYPE & TYPO3_REQUESTTYPE_CLI); } diff --git a/typo3/sysext/backend/Classes/Http/AjaxRequestHandler.php b/typo3/sysext/backend/Classes/Http/AjaxRequestHandler.php index 306d7d2d501f5fae9bf5e63b14f60812d6ef5535..554ad8fb2de0dc451d3d3c419beea9d7f5ba4a4b 100644 --- a/typo3/sysext/backend/Classes/Http/AjaxRequestHandler.php +++ b/typo3/sysext/backend/Classes/Http/AjaxRequestHandler.php @@ -15,7 +15,7 @@ namespace TYPO3\CMS\Backend\Http; */ use TYPO3\CMS\Core\Core\Bootstrap; -use TYPO3\CMS\Core\Core\RequestHandlerInterface; +use TYPO3\CMS\Core\Http\RequestHandlerInterface; use TYPO3\CMS\Core\Utility\GeneralUtility; use Psr\Http\Message\ServerRequestInterface; diff --git a/typo3/sysext/backend/Classes/Http/Application.php b/typo3/sysext/backend/Classes/Http/Application.php index 01ebd90ba6adddc2ec9d925190a247ba7806f201..b860541aebd282fba4ba4279a5e17a042f85d81b 100644 --- a/typo3/sysext/backend/Classes/Http/Application.php +++ b/typo3/sysext/backend/Classes/Http/Application.php @@ -65,6 +65,8 @@ class Application implements ApplicationInterface { foreach ($this->availableRequestHandlers as $requestHandler) { $this->bootstrap->registerRequestHandlerImplementation($requestHandler); } + + $this->bootstrap->configure(); } /** @@ -74,7 +76,7 @@ class Application implements ApplicationInterface { * @return void */ public function run(callable $execute = NULL) { - $this->bootstrap->run(); + $this->bootstrap->handleRequest(\TYPO3\CMS\Core\Http\ServerRequestFactory::fromGlobals()); if ($execute !== NULL) { if ($execute instanceof \Closure) { diff --git a/typo3/sysext/backend/Classes/Http/BackendModuleRequestHandler.php b/typo3/sysext/backend/Classes/Http/BackendModuleRequestHandler.php index e31d852aad95b6697a2fb4e80289ff14a42e6d27..de2567134b905ec6bbd274fda73f6f29b6a942c9 100644 --- a/typo3/sysext/backend/Classes/Http/BackendModuleRequestHandler.php +++ b/typo3/sysext/backend/Classes/Http/BackendModuleRequestHandler.php @@ -18,6 +18,7 @@ use TYPO3\CMS\Core\Authentication\BackendUserAuthentication; use TYPO3\CMS\Core\Core\Bootstrap; use TYPO3\CMS\Core\FormProtection\FormProtectionFactory; use TYPO3\CMS\Core\Exception; +use TYPO3\CMS\Core\Http\RequestHandlerInterface; use TYPO3\CMS\Core\Utility\GeneralUtility; use TYPO3\CMS\Extbase\Object\ObjectManager; use Psr\Http\Message\ServerRequestInterface; @@ -25,7 +26,7 @@ use Psr\Http\Message\ServerRequestInterface; /** * Handles the request for backend modules and wizards */ -class BackendModuleRequestHandler implements \TYPO3\CMS\Core\Core\RequestHandlerInterface { +class BackendModuleRequestHandler implements RequestHandlerInterface { /** * @var Bootstrap diff --git a/typo3/sysext/backend/Classes/Http/RequestHandler.php b/typo3/sysext/backend/Classes/Http/RequestHandler.php index 489616e4d63e1bc7735a27ffbf05855319a6b411..2860c426baf813ce9fb4910fca64a0084605cee0 100644 --- a/typo3/sysext/backend/Classes/Http/RequestHandler.php +++ b/typo3/sysext/backend/Classes/Http/RequestHandler.php @@ -15,7 +15,7 @@ namespace TYPO3\CMS\Backend\Http; */ use TYPO3\CMS\Core\Core\Bootstrap; -use TYPO3\CMS\Core\Core\RequestHandlerInterface; +use TYPO3\CMS\Core\Http\RequestHandlerInterface; use TYPO3\CMS\Core\Utility\GeneralUtility; /** @@ -84,7 +84,7 @@ class RequestHandler implements RequestHandlerInterface { /** * This request handler can handle any backend request (but not CLI). * - * @param \Psr\Http\Message\ServerRequestInterface $request + * @param \Psr\Http\Message\ServerRequestInterface|\TYPO3\CMS\Core\Console\Request $request * @return bool If the request is not a CLI script, TRUE otherwise FALSE */ public function canHandleRequest(\Psr\Http\Message\ServerRequestInterface $request) { diff --git a/typo3/sysext/core/Classes/Console/RequestHandlerInterface.php b/typo3/sysext/core/Classes/Console/RequestHandlerInterface.php new file mode 100644 index 0000000000000000000000000000000000000000..32cf5494bb3864bde003e37cce6cca427f2f6dbf --- /dev/null +++ b/typo3/sysext/core/Classes/Console/RequestHandlerInterface.php @@ -0,0 +1,54 @@ +<?php +namespace TYPO3\CMS\Core\Console; + +/* + * This file is part of the TYPO3 CMS project. + * + * It is free software; you can redistribute it and/or modify it under + * the terms of the GNU General Public License, either version 2 + * of the License, or any later version. + * + * For the full copyright and license information, please read the + * LICENSE.txt file that was distributed with this source code. + * + * The TYPO3 project - inspiring people to share! + */ +use Symfony\Component\Console\Input\InputInterface; +use Symfony\Component\Console\Output\OutputInterface; + +/** + * The interface for a request handler for a console-based application + * + * @api + */ +interface RequestHandlerInterface { + + /** + * Handles a raw request + * + * @param InputInterface $request + * @return NULL|OutputInterface + * @api + */ + public function handleRequest(InputInterface $request); + + /** + * Checks if the request handler can handle the given request. + * + * @param InputInterface $request + * @return bool TRUE if it can handle the request, otherwise FALSE + * @api + */ + public function canHandleRequest(InputInterface $request); + + /** + * Returns the priority - how eager the handler is to actually handle the + * request. An integer > 0 means "I want to handle this request" where + * "100" is default. "0" means "I am a fallback solution". + * + * @return int The priority of the request handler + * @api + */ + public function getPriority(); + +} diff --git a/typo3/sysext/core/Classes/Core/Bootstrap.php b/typo3/sysext/core/Classes/Core/Bootstrap.php index 616878bdb8b915ef830d72c91239487c3a88c6ed..8c88d91465e34679f7209b27fff575c7c5fd948f 100644 --- a/typo3/sysext/core/Classes/Core/Bootstrap.php +++ b/typo3/sysext/core/Classes/Core/Bootstrap.php @@ -74,7 +74,7 @@ class Bootstrap { /** * A list of all registered request handlers, see the Application class / entry points for the registration - * @var RequestHandlerInterface[] + * @var \TYPO3\CMS\Core\Http\RequestHandlerInterface[]|\TYPO3\CMS\Core\Console\RequestHandlerInterface[] */ protected $availableRequestHandlers = array(); @@ -164,14 +164,13 @@ class Bootstrap { /** * Main entry point called at every request usually from Global scope. Checks if everything is correct, - * and sets up the base request information for a regular request, then - * resolves the RequestHandler which handles the request. + * and loads the Configuration. * * Make sure that the baseSetup() is called before and the class loader is present * * @return Bootstrap */ - public function run() { + public function configure() { $this->startOutputBuffering() ->loadConfigurationAndInitialize() ->loadTypo3LoadedExtAndExtLocalconf(TRUE) @@ -179,8 +178,7 @@ class Bootstrap { ->setFinalCachingFrameworkCacheConfiguration() ->defineLoggingAndExceptionConstants() ->unsetReservedGlobalVariables() - ->initializeTypo3DbGlobal() - ->handleRequest(); + ->initializeTypo3DbGlobal(); return $this; } @@ -259,12 +257,12 @@ class Bootstrap { * Be sure to always have the constants that are defined in $this->defineTypo3RequestTypes() are set, * so most RequestHandlers can check if they can handle the request. * - * @param \Psr\Http\Message\ServerRequestInterface $request - * @return RequestHandlerInterface + * @param \Psr\Http\Message\RequestInterface|\Symfony\Component\Console\Input\InputInterface $request + * @return \TYPO3\CMS\Core\Http\RequestHandlerInterface|\TYPO3\CMS\Core\Console\RequestHandlerInterface * @throws \TYPO3\CMS\Core\Exception * @internal This is not a public API method, do not use in own extensions */ - protected function resolveRequestHandler(\Psr\Http\Message\ServerRequestInterface $request) { + protected function resolveRequestHandler($request) { $suitableRequestHandlers = array(); foreach ($this->availableRequestHandlers as $requestHandlerClassName) { $requestHandler = GeneralUtility::makeInstance($requestHandlerClassName, $this); @@ -287,13 +285,12 @@ class Bootstrap { * Builds a Request instance from the current process, and then resolves the request * through the request handlers depending on Frontend, Backend, CLI etc. * + * @param \Psr\Http\Message\RequestInterface|\Symfony\Component\Console\Input\InputInterface $request * @return Bootstrap * @throws \TYPO3\CMS\Core\Exception * @internal This is not a public API method, do not use in own extensions */ - public function handleRequest() { - // Build the Request object - $request = \TYPO3\CMS\Core\Http\ServerRequestFactory::fromGlobals(); + public function handleRequest($request) { // Resolve request handler that were registered based on the Application $requestHandler = $this->resolveRequestHandler($request); diff --git a/typo3/sysext/core/Classes/Core/RequestHandlerInterface.php b/typo3/sysext/core/Classes/Http/RequestHandlerInterface.php similarity index 97% rename from typo3/sysext/core/Classes/Core/RequestHandlerInterface.php rename to typo3/sysext/core/Classes/Http/RequestHandlerInterface.php index 7af6f4258c5542a909ebd4210bf4ad2abe30cee0..33c66b67b2e7b4de3eeab77651edee28a130ae66 100644 --- a/typo3/sysext/core/Classes/Core/RequestHandlerInterface.php +++ b/typo3/sysext/core/Classes/Http/RequestHandlerInterface.php @@ -1,5 +1,5 @@ <?php -namespace TYPO3\CMS\Core\Core; +namespace TYPO3\CMS\Core\Http; /* * This file is part of the TYPO3 CMS project. diff --git a/typo3/sysext/core/Classes/Http/ServerRequestFactory.php b/typo3/sysext/core/Classes/Http/ServerRequestFactory.php index 73014f111d4161e915b9e76bda56462627fbbf42..85b5aec569d224dd7b7a1597d72f73380206f68b 100644 --- a/typo3/sysext/core/Classes/Http/ServerRequestFactory.php +++ b/typo3/sysext/core/Classes/Http/ServerRequestFactory.php @@ -125,7 +125,7 @@ class ServerRequestFactory { * Create and return an UploadedFile instance from a $_FILES specification. * * If the specification represents an array of values, this method will - * delegate to normalizeNestedFileSpec() and return that return value. + * recursively resolve uploaded files. * * @param array $value $_FILES structure * @return UploadedFileInterface[]|UploadedFileInterface diff --git a/typo3/sysext/frontend/Classes/Http/Application.php b/typo3/sysext/frontend/Classes/Http/Application.php index 8c3f3d02f1215618a2d155a9f246636d207106ff..4ca07a8fc3a0a7b077616776cc794a9d541b6475 100644 --- a/typo3/sysext/frontend/Classes/Http/Application.php +++ b/typo3/sysext/frontend/Classes/Http/Application.php @@ -62,6 +62,8 @@ class Application implements ApplicationInterface { foreach ($this->availableRequestHandlers as $requestHandler) { $this->bootstrap->registerRequestHandlerImplementation($requestHandler); } + + $this->bootstrap->configure(); } /** @@ -71,7 +73,7 @@ class Application implements ApplicationInterface { * @return void */ public function run(callable $execute = NULL) { - $this->bootstrap->run(); + $this->bootstrap->handleRequest(\TYPO3\CMS\Core\Http\ServerRequestFactory::fromGlobals()); if ($execute !== NULL) { if ($execute instanceof \Closure) { diff --git a/typo3/sysext/frontend/Classes/Http/EidRequestHandler.php b/typo3/sysext/frontend/Classes/Http/EidRequestHandler.php index 81cb6fb4efca0c98a2b322b9bdfdbfbec6948f45..09dcbc6d9825983da32036e8aa63853fb29fbc36 100644 --- a/typo3/sysext/frontend/Classes/Http/EidRequestHandler.php +++ b/typo3/sysext/frontend/Classes/Http/EidRequestHandler.php @@ -19,7 +19,7 @@ use TYPO3\CMS\Core\TimeTracker\NullTimeTracker; use TYPO3\CMS\Core\TimeTracker\TimeTracker; use TYPO3\CMS\Frontend\Utility\EidUtility; use TYPO3\CMS\Core\Utility\GeneralUtility; -use TYPO3\CMS\Core\Core\RequestHandlerInterface; +use TYPO3\CMS\Core\Http\RequestHandlerInterface; use Psr\Http\Message\ServerRequestInterface; /** diff --git a/typo3/sysext/frontend/Classes/Http/RequestHandler.php b/typo3/sysext/frontend/Classes/Http/RequestHandler.php index b223440ee214e0930e4a9825d70410b934a4fd7b..9ecf4983656424508c8dad34b4ad7c4b01c5eb17 100644 --- a/typo3/sysext/frontend/Classes/Http/RequestHandler.php +++ b/typo3/sysext/frontend/Classes/Http/RequestHandler.php @@ -16,7 +16,7 @@ namespace TYPO3\CMS\Frontend\Http; use TYPO3\CMS\Backend\FrontendBackendUserAuthentication; use TYPO3\CMS\Core\Core\Bootstrap; -use TYPO3\CMS\Core\Core\RequestHandlerInterface; +use TYPO3\CMS\Core\Http\RequestHandlerInterface; use TYPO3\CMS\Core\FrontendEditing\FrontendEditingController; use TYPO3\CMS\Core\TimeTracker\NullTimeTracker; use TYPO3\CMS\Core\TimeTracker\TimeTracker; diff --git a/typo3/sysext/install/Classes/Http/Application.php b/typo3/sysext/install/Classes/Http/Application.php index 4a44a26db4fc6632e86338929de52ce20842f0b5..bd85360fe3f75b68457299f6f822be2319fa0928 100644 --- a/typo3/sysext/install/Classes/Http/Application.php +++ b/typo3/sysext/install/Classes/Http/Application.php @@ -55,6 +55,10 @@ class Application implements ApplicationInterface { foreach ($this->availableRequestHandlers as $requestHandler) { $this->bootstrap->registerRequestHandlerImplementation($requestHandler); } + + $this->bootstrap + ->startOutputBuffering() + ->loadConfigurationAndInitialize(FALSE, \TYPO3\CMS\Core\Package\FailsafePackageManager::class); } /** @@ -66,10 +70,7 @@ class Application implements ApplicationInterface { * @return void */ public function run(callable $execute = NULL) { - $this->bootstrap - ->startOutputBuffering() - ->loadConfigurationAndInitialize(FALSE, \TYPO3\CMS\Core\Package\FailsafePackageManager::class) - ->handleRequest(); + $this->bootstrap->handleRequest(\TYPO3\CMS\Core\Http\ServerRequestFactory::fromGlobals()); if ($execute !== NULL) { if ($execute instanceof \Closure) { diff --git a/typo3/sysext/install/Classes/Http/RequestHandler.php b/typo3/sysext/install/Classes/Http/RequestHandler.php index 6ccce1e3474e4bea48374d3e3e527f51b0033196..3eae52f0306ec876fce1282e548b9e16aa6284a5 100644 --- a/typo3/sysext/install/Classes/Http/RequestHandler.php +++ b/typo3/sysext/install/Classes/Http/RequestHandler.php @@ -16,7 +16,7 @@ namespace TYPO3\CMS\Install\Http; use Psr\Http\Message\ServerRequestInterface; use TYPO3\CMS\Core\Core\Bootstrap; -use TYPO3\CMS\Core\Core\RequestHandlerInterface; +use TYPO3\CMS\Core\Http\RequestHandlerInterface; use TYPO3\CMS\Core\Utility\GeneralUtility; /**