[TASK] Check for Extbase response type instead of environment 00/58200/3
authorDaniel Siepmann <daniel.siepmann@typo3.org>
Thu, 6 Sep 2018 12:36:16 +0000 (14:36 +0200)
committerMarkus Klein <markus.klein@typo3.org>
Sun, 28 Oct 2018 14:12:58 +0000 (15:12 +0100)
Functional tests always set CLI context to true. Even if Extbase returns
an Web\Response, the method getExitCode will be called, which only
exists in Cli\Response.

Therefore a check against the response type allows to run functional
tests with Web\Response in Extbase.

Resolves: #86170
Releases: master
Change-Id: I5982d77aad82f92b6e6bb13cca5118ea2a3e7796
Reviewed-on: https://review.typo3.org/58200
Reviewed-by: Benni Mack <benni@typo3.org>
Tested-by: Benni Mack <benni@typo3.org>
Reviewed-by: Markus Klein <markus.klein@typo3.org>
Tested-by: Markus Klein <markus.klein@typo3.org>
typo3/sysext/extbase/Classes/Core/Bootstrap.php

index 19e5d2c..27e1d30 100644 (file)
@@ -18,7 +18,8 @@ use Psr\Http\Message\ResponseInterface;
 use Psr\Http\Message\ServerRequestInterface;
 use TYPO3\CMS\Backend\Routing\Route;
 use TYPO3\CMS\Core\Core\Environment;
-use TYPO3\CMS\Extbase\Mvc\Web\Response;
+use TYPO3\CMS\Extbase\Mvc\Cli\Response as CliResponse;
+use TYPO3\CMS\Extbase\Mvc\Web\Response as WebResponse;
 
 /**
  * Creates a request an dispatches it to the controller which was specified
@@ -178,7 +179,7 @@ class Bootstrap implements \TYPO3\CMS\Extbase\Core\BootstrapInterface
             $content = $response->shutdown();
             $this->resetSingletons();
             $this->objectManager->get(\TYPO3\CMS\Extbase\Service\CacheService::class)->clearCachesOfRegisteredPageIds();
-            if (Environment::isCli() && $response->getExitCode()) {
+            if ($response instanceof CliResponse && $response->getExitCode()) {
                 throw new \TYPO3\CMS\Extbase\Mvc\Exception\CommandException('The request has been terminated as the response defined an exit code.', $response->getExitCode());
             }
         }
@@ -212,7 +213,7 @@ class Bootstrap implements \TYPO3\CMS\Extbase\Core\BootstrapInterface
         /** @var \TYPO3\CMS\Extbase\Mvc\RequestHandlerResolver $requestHandlerResolver */
         $requestHandlerResolver = $this->objectManager->get(\TYPO3\CMS\Extbase\Mvc\RequestHandlerResolver::class);
         $requestHandler = $requestHandlerResolver->resolveRequestHandler();
-        /** @var Response $extbaseResponse */
+        /** @var WebResponse $extbaseResponse */
         $extbaseResponse = $requestHandler->handleRequest();
 
         // Convert to PSR-7 response and hand it back to TYPO3 Core
@@ -225,10 +226,10 @@ class Bootstrap implements \TYPO3\CMS\Extbase\Core\BootstrapInterface
     /**
      * Converts a Extbase response object into a PSR-7 Response
      *
-     * @param Response $extbaseResponse
+     * @param WebResponse $extbaseResponse
      * @return ResponseInterface
      */
-    protected function convertExtbaseResponseToPsr7Response(Response $extbaseResponse): ResponseInterface
+    protected function convertExtbaseResponseToPsr7Response(WebResponse $extbaseResponse): ResponseInterface
     {
         $response = new \TYPO3\CMS\Core\Http\Response(
             'php://temp',