From c19c11c0376a999548394fdf88898fe63e39bdde Mon Sep 17 00:00:00 2001 From: Christian Kuhn <lolli@schwarzbu.ch> Date: Sun, 8 Aug 2021 14:55:38 +0200 Subject: [PATCH] [TASK] Avoid request dependent data in scheduler test task Accessing request dependent data in a scheduler task is problematic on CLI. For this reason tasks have no setRequest() method or similar. The task does not loose much information avoiding a GU::getIndpEnv() for the test mail, and the setRequest() on the mail object is unused. Change-Id: I87a74c1d48eaa894c2859b235886ed57300c8a8b Resolves: #94748 Related: #94632 Releases: master Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/70289 Tested-by: core-ci <typo3@b13.com> Tested-by: Anja Leichsenring <aleichsenring@ab-softlab.de> Tested-by: Benni Mack <benni@typo3.org> Reviewed-by: Anja Leichsenring <aleichsenring@ab-softlab.de> Reviewed-by: Benni Mack <benni@typo3.org> --- typo3/sysext/scheduler/Classes/Example/TestTask.php | 8 -------- .../Resources/Private/Templates/Email/TestTask.html | 1 - .../Resources/Private/Templates/Email/TestTask.txt | 1 - 3 files changed, 10 deletions(-) diff --git a/typo3/sysext/scheduler/Classes/Example/TestTask.php b/typo3/sysext/scheduler/Classes/Example/TestTask.php index 150153fedac0..dd8e62948f8a 100644 --- a/typo3/sysext/scheduler/Classes/Example/TestTask.php +++ b/typo3/sysext/scheduler/Classes/Example/TestTask.php @@ -15,7 +15,6 @@ namespace TYPO3\CMS\Scheduler\Example; -use Psr\Http\Message\ServerRequestInterface; use Symfony\Component\Mime\Address; use TYPO3\CMS\Core\Core\Environment; use TYPO3\CMS\Core\Mail\FluidEmail; @@ -54,10 +53,8 @@ class TestTask extends AbstractTask if (Environment::isCli()) { $calledBy = 'CLI module dispatcher'; - $site = '-'; } else { $calledBy = 'TYPO3 backend'; - $site = GeneralUtility::getIndpEnv('TYPO3_SITE_URL'); } $email = GeneralUtility::makeInstance( FluidEmail::class, @@ -75,7 +72,6 @@ class TestTask extends AbstractTask [ 'data' => [ 'uid' => $this->taskUid, - 'site' => $site, 'calledBy' => $calledBy, 'tstamp' => time(), 'maxLifetime' => $this->scheduler->extConf['maxLifetime'], @@ -83,10 +79,6 @@ class TestTask extends AbstractTask 'exec' => $this->getExecution() ] ); - - if ($GLOBALS['TYPO3_REQUEST'] instanceof ServerRequestInterface) { - $email->setRequest($GLOBALS['TYPO3_REQUEST']); - } GeneralUtility::makeInstance(Mailer::class)->send($email); return true; } diff --git a/typo3/sysext/scheduler/Resources/Private/Templates/Email/TestTask.html b/typo3/sysext/scheduler/Resources/Private/Templates/Email/TestTask.html index fac18d2d26fb..6605b571aa91 100644 --- a/typo3/sysext/scheduler/Resources/Private/Templates/Email/TestTask.html +++ b/typo3/sysext/scheduler/Resources/Private/Templates/Email/TestTask.html @@ -3,7 +3,6 @@ <f:section name="Main"> <strong>UID:</strong> {data.uid}<br> <strong>Sitename:</strong> {typo3.sitename}<br> - <strong>Site:</strong> {data.site}<br> <strong>Called by:</strong> {data.calledBy}<br> <strong>Tstamp:</strong> {f:format.date(format:'Y-m-d H:i:s',date:data.tstamp)} [{data.tstamp}]<br> <strong>maxLifetime:</strong> {data.maxLifetime}<br> diff --git a/typo3/sysext/scheduler/Resources/Private/Templates/Email/TestTask.txt b/typo3/sysext/scheduler/Resources/Private/Templates/Email/TestTask.txt index 776068251900..85785349f327 100644 --- a/typo3/sysext/scheduler/Resources/Private/Templates/Email/TestTask.txt +++ b/typo3/sysext/scheduler/Resources/Private/Templates/Email/TestTask.txt @@ -3,7 +3,6 @@ <f:section name="Main"> UID: {data.uid} Sitename: {typo3.sitename} -Site: {data.site} Called by: {data.calledBy} Tstamp: {f:format.date(format:'Y-m-d H:i:s',date:data.tstamp)} [{data.tstamp}] maxLifetime: {data.maxLifetime} -- GitLab