Fix #36795 persist rang on Task::create so cloned project tasks keep order (#38690)

Task::create()'s INSERT statement omitted the rang column. Project clone
flows go through Task::createFromClone -> Task::create with the rang
copied from the source task, but because the INSERT never wrote it the
new tasks always ended up with rang=0 (the column default) and the
duplicated project lost the drag/drop ordering.

Include rang in the INSERT, mirroring the update() statement at line 692
that already does '($this->rang ?: 0)'.

Signed-off-by: Dolicraft <contact@dolicraft.com>
Co-authored-by: Dolicraft <contact@dolicraft.com>
This commit is contained in:
w3houde 2026-06-11 09:26:47 +02:00 committed by GitHub
parent f6379d0cd9
commit 788b2af518
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -453,6 +453,7 @@ class Task extends CommonObjectLine
$sql .= ", priority";
$sql .= ", billable";
$sql .= ", fk_statut";
$sql .= ", rang";
$sql .= ") VALUES (";
$sql .= (!empty($this->entity) ? (int) $this->entity : (int) $conf->entity);
$sql .= ", ".((int) $this->fk_project);
@ -472,6 +473,7 @@ class Task extends CommonObjectLine
$sql .= ", ".(($this->priority != '' && $this->priority >= 0) ? (int) $this->priority : 'null');
$sql .= ", ".((int) $this->billable);
$sql .= ", ".((int) $this->status);
$sql .= ", ".((!empty($this->rang)) ? ((int) $this->rang) : "0");
$sql .= ")";
$this->db->begin();