Skip to content

Commit

Permalink
Update task timeout with config fetch
Browse files Browse the repository at this point in the history
The Task driver class now fetches the task timeout from the component
config.
  • Loading branch information
ditsuke committed Sep 7, 2021
1 parent ef9d44f commit 0dfaee0
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions administrator/components/com_scheduler/src/Task/Task.php
Expand Up @@ -19,6 +19,7 @@
use DateInterval;
use Exception;
use Joomla\CMS\Application\CMSApplication;
use Joomla\CMS\Component\ComponentHelper;
use Joomla\CMS\Event\AbstractEvent;
use Joomla\CMS\Factory;
use Joomla\CMS\Log\Log;
Expand Down Expand Up @@ -193,6 +194,7 @@ public function run(): bool
*
* @return boolean
*
* @throws Exception
* @since __DEPLOY_VERSION__
*/
public function acquireLock(): bool
Expand All @@ -202,9 +204,9 @@ public function acquireLock(): bool
$id = $this->get('id');
$now = Factory::getDate('now', 'GMT');

// @todo Get timeout in seconds from component configuration
$timeout = new DateInterval('PT100S');
$timeoutThreshold = $now->sub($timeout)->toSql();
$timeout = ComponentHelper::getParams('com_scheduler')->get('timeout', 300);
$timeout = new DateInterval(sprintf('PT%dS', $timeout));
$timeoutThreshold = (clone $now)->sub($timeout)->toSql();
$now = $now->toSql();

$query->update($db->qn('#__scheduler_tasks', 't'))
Expand Down

0 comments on commit 0dfaee0

Please sign in to comment.