Skip to content

Commit

Permalink
fix(Admin/SchedulerTask): allow update admin task without config
Browse files Browse the repository at this point in the history
  • Loading branch information
ccheng-dev authored and paulmhh committed Aug 12, 2024
1 parent 546c787 commit 1be6519
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 2 deletions.
27 changes: 27 additions & 0 deletions tests/tine20/Admin/Controller/SchedulerTaskTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,4 +54,31 @@ public function testSearchSchedulerTask()
]), new Tinebase_Model_Pagination(['sort' => 'name', 'dir' => 'desc']));
$this->assertNotNull($result);
}

public function testUpdateSchedulerTask()
{
$scheduler = Tinebase_Core::getScheduler();
$task = new Tinebase_Model_SchedulerTask([
'name' => 'test',
'config' => new Tinebase_Scheduler_Task([
'cron' => Tinebase_Scheduler_Task::TASK_TYPE_MINUTELY,
'callables' => [
[
Tinebase_Scheduler_Task::CLASS_NAME => Scheduler_Mock::class,
Tinebase_Scheduler_Task::METHOD_NAME => 'run'
], [
Tinebase_Scheduler_Task::CONTROLLER => Tinebase_Scheduler::class,
Tinebase_Scheduler_Task::METHOD_NAME => 'doContainerACLChecks',
Tinebase_Scheduler_Task::ARGS => [true]
]
]
]),
'next_run' => Tinebase_DateTime::now()->subDay(100)
]);
$createdTask = $scheduler->create($task);
$createdTask['next_run'] = Tinebase_DateTime::now();

$this->expectException(Tinebase_Exception_AccessDenied::class);
$updatedTask = Admin_Controller_SchedulerTask::getInstance()->update($createdTask);
}
}
6 changes: 4 additions & 2 deletions tine20/Tinebase/Record/NewAbstract.php
Original file line number Diff line number Diff line change
Expand Up @@ -429,8 +429,10 @@ public function setFromArray(array &$_data)
$this->{$fieldName}->runConvertToRecord();
} elseif (self::TYPE_DYNAMIC_RECORD === $config[self::TYPE]) {
$modelName = $this->{$config[self::CONFIG][self::REF_MODEL_FIELD]};
$this->{$fieldName} = new $modelName($_data[$fieldName], $this->bypassFilters, true);
$this->{$fieldName}->runConvertToRecord();
if (is_string($modelName) && is_a($modelName, Tinebase_Record_Interface::class, true)) {
$this->{$fieldName} = new $modelName($_data[$fieldName], $this->bypassFilters, true);
$this->{$fieldName}->runConvertToRecord();
}
}
}
}
Expand Down

0 comments on commit 1be6519

Please sign in to comment.