[BUGFIX] Add exit code support to extbase commands 91/42291/26
authorJan Runte <jan.runte@hmmh.de>
Wed, 5 Aug 2015 19:01:02 +0000 (21:01 +0200)
committerBenni Mack <benni@typo3.org>
Sat, 26 Sep 2015 14:40:02 +0000 (16:40 +0200)
If an exit code is defined in CliResponse an exception is
thrown which contains the exit code as exception code.
The exception will be catched in CliRequestHandler::handleRequest
and the exception code will then be used as exit code.

Change-Id: I0c45e55531409d69c6cc6fe4888f97b5f117cef4
Resolves: #58781
Releases: master
Reviewed-on: http://review.typo3.org/42291
Reviewed-by: Stefan Froemken <froemken@gmail.com>
Tested-by: Stefan Froemken <froemken@gmail.com>
Reviewed-by: Benni Mack <benni@typo3.org>
Tested-by: Benni Mack <benni@typo3.org>
typo3/sysext/extbase/Classes/Core/Bootstrap.php

index 42f9f27..61fc099 100644 (file)
@@ -186,6 +186,7 @@ class Bootstrap implements \TYPO3\CMS\Extbase\Core\BootstrapInterface {
        }
 
        /**
+        * @throws \TYPO3\CMS\Extbase\Mvc\Exception\CommandException Is thrown if the response object defined an exit code > 0
         * @return string
         */
        protected function handleRequest() {
@@ -204,6 +205,9 @@ class Bootstrap implements \TYPO3\CMS\Extbase\Core\BootstrapInterface {
                        $content = $response->shutdown();
                        $this->resetSingletons();
                        $this->objectManager->get(\TYPO3\CMS\Extbase\Service\CacheService::class)->clearCachesOfRegisteredPageIds();
+                       if ($this->isInCliMode() && $response->getExitCode()) {
+                               throw new \TYPO3\CMS\Extbase\Mvc\Exception\CommandException('The request has been terminated as the response defined an exit code.', $response->getExitCode());
+                       }
                }
 
                return $content;