mirror of
https://github.com/pterodactyl/panel.git
synced 2024-11-22 00:52:43 +01:00
api(task): ensure sequence_id
always starts at 1
This commit is contained in:
parent
2b14e46eec
commit
866b6df4b0
@ -56,6 +56,11 @@ class ScheduleTaskController extends ClientApiController
|
||||
$sequenceId = ($lastTask->sequence_id ?? 0) + 1;
|
||||
$requestSequenceId = $request->integer('sequence_id', $sequenceId);
|
||||
|
||||
// Ensure that the sequence id is at least 1.
|
||||
if ($requestSequenceId < 1) {
|
||||
$requestSequenceId = 1;
|
||||
}
|
||||
|
||||
// If the sequence id from the request is greater than or equal to the next available
|
||||
// sequence id, we don't need to do anything special. Otherwise, we need to update
|
||||
// the sequence id of all tasks that are greater than or equal to the request sequence
|
||||
@ -105,6 +110,10 @@ class ScheduleTaskController extends ClientApiController
|
||||
|
||||
$this->connection->transaction(function () use ($request, $schedule, $task) {
|
||||
$sequenceId = $request->integer('sequence_id', $task->sequence_id);
|
||||
// Ensure that the sequence id is at least 1.
|
||||
if ($sequenceId < 1) {
|
||||
$sequenceId = 1;
|
||||
}
|
||||
|
||||
// Shift all other tasks in the schedule up or down to make room for the new task.
|
||||
if ($sequenceId < $task->sequence_id) {
|
||||
|
Loading…
Reference in New Issue
Block a user