Merged in bugfix/PMCORE-3906 (pull request #8514)

PMCORE-3906 Task Scheduler does not work for stacks N285 and 285

Approved-by: Julio Cesar Laura Avendaño
This commit is contained in:
Roly Gutierrez
2022-08-15 13:19:57 +00:00
committed by Julio Cesar Laura Avendaño

View File

@@ -43,7 +43,6 @@ class ScheduleRunCommand extends BaseCommand
*/ */
public function handle(Schedule $schedule, Dispatcher $dispatcher, ExceptionHandler $handler) public function handle(Schedule $schedule, Dispatcher $dispatcher, ExceptionHandler $handler)
{ {
$that = $this;
$workspace = $this->option('workspace'); $workspace = $this->option('workspace');
$user = $this->option('user'); $user = $this->option('user');
if (!empty($workspace)) { if (!empty($workspace)) {
@@ -51,7 +50,7 @@ class ScheduleRunCommand extends BaseCommand
$webApplication->setRootDir($this->option('processmakerPath')); $webApplication->setRootDir($this->option('processmakerPath'));
$webApplication->loadEnvironment($workspace, false); $webApplication->loadEnvironment($workspace, false);
} }
TaskScheduler::all()->each(function ($p) use ($that, $user) { TaskScheduler::all()->each(function ($p) use ($schedule, $user) {
$win = strtoupper(substr(PHP_OS, 0, 3)) === 'WIN'; $win = strtoupper(substr(PHP_OS, 0, 3)) === 'WIN';
if ($p->enable == 1) { if ($p->enable == 1) {
$starting = isset($p->startingTime) ? $p->startingTime : "0:00"; $starting = isset($p->startingTime) ? $p->startingTime : "0:00";
@@ -78,7 +77,7 @@ class ScheduleRunCommand extends BaseCommand
$body = str_replace("report_by_process", "report_by_process +init-date'{$oneMonthAgo}' +finish-date'{$currentDate}'", $body); $body = str_replace("report_by_process", "report_by_process +init-date'{$oneMonthAgo}' +finish-date'{$currentDate}'", $body);
} }
$schedule = $that->schedule->exec($body)->cron($p->expression)->between($starting, $ending)->timezone($timezone)->when(function () use ($p) { $schedule->exec($body)->cron($p->expression)->between($starting, $ending)->timezone($timezone)->when(function () use ($p) {
$now = Carbon::now(); $now = Carbon::now();
$result = false; $result = false;
$datework = Carbon::createFromFormat('Y-m-d H:i:s', $p->last_update); $datework = Carbon::createFromFormat('Y-m-d H:i:s', $p->last_update);