Skip to content

Commit

Permalink
[TASK] Use Environment API in scheduler
Browse files Browse the repository at this point in the history
Resolves: #85279
Releases: master
Change-Id: I2d63540be1883fb2faea763d72a875800eae1cfa
Reviewed-on: https://review.typo3.org/57236
Reviewed-by: Jan Helke <typo3@helke.de>
Tested-by: TYPO3com <no-reply@typo3.com>
Tested-by: Jan Helke <typo3@helke.de>
Reviewed-by: Christian Kuhn <lolli@schwarzbu.ch>
Tested-by: Christian Kuhn <lolli@schwarzbu.ch>
  • Loading branch information
bmack authored and lolli42 committed Jun 15, 2018
1 parent f1ae421 commit 506e6e5
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 7 deletions.
3 changes: 2 additions & 1 deletion typo3/sysext/scheduler/Classes/Example/TestTask.php
Expand Up @@ -14,6 +14,7 @@
* The TYPO3 project - inspiring people to share!
*/

use TYPO3\CMS\Core\Core\Environment;
use TYPO3\CMS\Core\Utility\GeneralUtility;

/**
Expand Down Expand Up @@ -43,7 +44,7 @@ public function execute()
// Get execution information
$exec = $this->getExecution();
// Get call method
if (TYPO3_REQUESTTYPE & TYPO3_REQUESTTYPE_CLI) {
if (Environment::isCli()) {
$calledBy = 'CLI module dispatcher';
$site = '-';
} else {
Expand Down
9 changes: 3 additions & 6 deletions typo3/sysext/scheduler/Classes/Task/AbstractTask.php
Expand Up @@ -16,6 +16,7 @@

use Psr\Log\LoggerAwareInterface;
use Psr\Log\LoggerAwareTrait;
use TYPO3\CMS\Core\Core\Environment;
use TYPO3\CMS\Core\Database\Connection;
use TYPO3\CMS\Core\Database\ConnectionPool;
use TYPO3\CMS\Core\Utility\GeneralUtility;
Expand Down Expand Up @@ -437,19 +438,15 @@ public function markExecution()
// (we need to know that number, because it is returned at the end of the method)
$numExecutions = count($runningExecutions);
$runningExecutions[$numExecutions] = time();
// Define the context in which the script is running
$context = 'BE';
if (TYPO3_REQUESTTYPE & TYPO3_REQUESTTYPE_CLI) {
$context = 'CLI';
}
GeneralUtility::makeInstance(ConnectionPool::class)
->getConnectionForTable('tx_scheduler_task')
->update(
'tx_scheduler_task',
[
'serialized_executions' => serialize($runningExecutions),
'lastexecution_time' => time(),
'lastexecution_context' => $context
// Define the context in which the script is running
'lastexecution_context' => Environment::isCli() ? 'CLI' : 'BE'
],
[
'uid' => $this->taskUid
Expand Down

0 comments on commit 506e6e5

Please sign in to comment.