[BUGFIX] Rethrow Extbase scheduler task exceptions 85/36985/4
authorMathias Brodala <mbrodala@pagemachine.de>
Wed, 18 Feb 2015 08:10:37 +0000 (09:10 +0100)
committerWouter Wolters <typo3@wouterwolters.nl>
Sat, 28 Feb 2015 16:35:20 +0000 (17:35 +0100)
This makes sure exception details thrown in Extbase scheduler tasks
can be shown by the Scheduler.

Resolves: #49071
Releases: master, 6.2
Change-Id: Ic703568715bf92523a9cbd0dcab6c5606ea278bb
Reviewed-on: http://review.typo3.org/36985
Reviewed-by: Alexander Opitz <opitz.alexander@googlemail.com>
Tested-by: Alexander Opitz <opitz.alexander@googlemail.com>
Reviewed-by: Wouter Wolters <typo3@wouterwolters.nl>
Tested-by: Wouter Wolters <typo3@wouterwolters.nl>
typo3/sysext/extbase/Classes/Scheduler/Task.php
typo3/sysext/extbase/Tests/Unit/Scheduler/TaskTest.php

index dd9f14a..68f2847 100644 (file)
@@ -86,16 +86,18 @@ class Task extends \TYPO3\CMS\Scheduler\Task\AbstractTask {
        /**
         * Function execute from the Scheduler
         *
-        * @return bool TRUE on successful execution, FALSE on error
+        * @return bool TRUE on successful execution
+        * @throws \Exception If an error occurs
         */
        public function execute() {
                try {
                        $this->taskExecutor->execute($this);
-                       return TRUE;
                } catch (\Exception $e) {
                        $this->logException($e);
-                       return FALSE;
+                       // Make sure the Scheduler gets exception details
+                       throw $e;
                }
+               return TRUE;
        }
 
        /**
index 39dff66..12c7ab7 100644 (file)
@@ -36,9 +36,10 @@ class TaskTest extends \TYPO3\CMS\Core\Tests\UnitTestCase {
 
        /**
         * @test
+        * @expectedException Exception
         * @author Alexander Schnitzler <alex.schnitzler@typovision.de>
         */
-       public function executeCallsLogExceptionOnCaughtException() {
+       public function executeCallsLogExceptionOnCaughtExceptionAndRethrowsException() {
                $this->taskExecutor->expects($this->once())->method('execute')->will($this->throwException(new \Exception()));
                $this->task->_set('taskExecutor', $this->taskExecutor);
                $this->task->expects($this->once())->method('logException');