From e216366a7938515b40598dd0b487854608faa657 Mon Sep 17 00:00:00 2001 From: Christian Weiske <weiske@mogic.com> Date: Tue, 7 May 2024 13:47:22 +0200 Subject: [PATCH] [BUGFIX] Add scheduler task exception to error message MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When a scheduler task throws an exception, an error is logged. The log message does not tell us the reason for the failure: > Task failed to execute successfully. > Class: TYPO3\CMS\Scheduler\Task\ExecuteSchedulableCommandTask, UID: 2 Up to TYPO3 v10, this message did include more information: > Task failed to execute successfully. > Class: TYPO3\CMS\Scheduler\Task\ExecuteSchedulableCommandTask, UID: 2, > Code: 56, OpenSSL SSL_read: Connection reset by peer, errno 104 This behavior was changed (probably unintentional) with patch "[BUGFIX] Make logger usage PSR-3 compliant" https://review.typo3.org/c/Packages/TYPO3.CMS/+/69425 Besides the task class and UID, the log message now contains the exception code, message, file and line. Example: > Task failed to execute successfully. > Class: TYPO3\CMS\Scheduler\Task\ExecuteSchedulableCommandTask, UID: 6, > Code: 500, "FailTask fail message" > in /var/www/typo3/vendor/[...]/Classes/Command/FailTask.php#19 Resolves: #103799 Related: #94356 Releases: main, 12.4 Change-Id: I179f059e551966944288b6fda6f2a26a4daace3b Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/84152 Tested-by: Stefan Bürk <stefan@buerk.tech> Reviewed-by: Georg Ringer <georg.ringer@gmail.com> Reviewed-by: Christian Kuhn <lolli@schwarzbu.ch> Tested-by: core-ci <typo3@b13.com> Tested-by: Georg Ringer <georg.ringer@gmail.com> Reviewed-by: Stefan Bürk <stefan@buerk.tech> Tested-by: Christian Kuhn <lolli@schwarzbu.ch> --- typo3/sysext/scheduler/Classes/Scheduler.php | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/typo3/sysext/scheduler/Classes/Scheduler.php b/typo3/sysext/scheduler/Classes/Scheduler.php index 5f91a82a69f2..eb9245ed54b1 100644 --- a/typo3/sysext/scheduler/Classes/Scheduler.php +++ b/typo3/sysext/scheduler/Classes/Scheduler.php @@ -170,10 +170,14 @@ class Scheduler implements SingletonInterface } } catch (\Throwable $e) { // Log failed execution - $this->logger->error('Task failed to execute successfully. Class: {class}, UID: {uid}', [ - 'class' => get_class($task), - 'uid' => $task->getTaskUid(), + $this->logger->error('Task failed to execute successfully. Class: {taskClass}, UID: {taskId}, Code: {code}, "{message}" in {exceptionFile} at line {exceptionLine}', [ + 'taskClass' => get_class($task), + 'taskId' => $task->getTaskUid(), 'exception' => $e, + 'exceptionFile' => $e->getFile(), + 'exceptionLine' => $e->getLine(), + 'code' => $e->getCode(), + 'message' => $e->getMessage(), ]); // Store exception, so that it can be saved to database // Do not serialize the complete exception or the trace, this can lead to huge strings > 50MB -- GitLab