From 4ef3987fc1c08501fd886c4b7777dcdf53fa6fe3 Mon Sep 17 00:00:00 2001
From: Mathias Brodala <mbrodala@pagemachine.de>
Date: Wed, 18 Feb 2015 09:10:37 +0100
Subject: [PATCH] [BUGFIX] Rethrow Extbase scheduler task exceptions

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        | 8 +++++---
 typo3/sysext/extbase/Tests/Unit/Scheduler/TaskTest.php | 3 ++-
 2 files changed, 7 insertions(+), 4 deletions(-)

diff --git a/typo3/sysext/extbase/Classes/Scheduler/Task.php b/typo3/sysext/extbase/Classes/Scheduler/Task.php
index dd9f14a12176..68f2847ac48a 100644
--- a/typo3/sysext/extbase/Classes/Scheduler/Task.php
+++ b/typo3/sysext/extbase/Classes/Scheduler/Task.php
@@ -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;
 	}
 
 	/**
diff --git a/typo3/sysext/extbase/Tests/Unit/Scheduler/TaskTest.php b/typo3/sysext/extbase/Tests/Unit/Scheduler/TaskTest.php
index 39dff66a7a05..12c7ab7c3804 100644
--- a/typo3/sysext/extbase/Tests/Unit/Scheduler/TaskTest.php
+++ b/typo3/sysext/extbase/Tests/Unit/Scheduler/TaskTest.php
@@ -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');
-- 
GitLab