From 94c2cfc48caa73dd460cd1561a5cfd507908368d Mon Sep 17 00:00:00 2001 From: Jeroen De Meerleer Date: Sat, 29 May 2021 11:56:29 +0200 Subject: [PATCH] Starttime by reference --- src/Repository/Job.php | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/src/Repository/Job.php b/src/Repository/Job.php index 398c9a0..81ad24f 100644 --- a/src/Repository/Job.php +++ b/src/Repository/Job.php @@ -174,7 +174,7 @@ class Job extends Repository return $return; } - private function runRebootJob(array $job, float $starttime): array + private function runRebootJob(array $job, float &$starttime): array { if($job['running'] == 1) { $this->setTempVar($job['id'], 'starttime', $starttime); @@ -203,6 +203,9 @@ class Job extends Repository if($job['running'] > time()) { exit; } + $starttime = (float)$this->getTempVar($job['id'], 'starttime'); + $this->deleteTempVar($job['id'], 'starttime'); + $jobsSql = "UPDATE job SET running = :status WHERE id = :id"; $jobsStmt = $this->dbcon->prepare($jobsSql); $jobsStmt->executeQuery([':id' => $job['id'], ':status' => 1]); @@ -218,10 +221,6 @@ class Job extends Repository $return = $this->runLocalCommand($job['data']['getservices-command']); } - $starttime = (float)$this->getTempVar($job['id'], 'starttime'); - $this->deleteTempVar($job['id'], 'starttime'); - $return['starttime'] = $starttime; - return $return; } } @@ -244,7 +243,6 @@ class Job extends Repository $result = $this->runCommandJob($job); } elseif($job['data']['crontype'] == 'reboot') { $result = $this->runRebootJob($job, $starttime); - $starttime = $result['starttime']; } $endtime = microtime(true); $runtime = $endtime - $starttime;