From 22045603b744134fa4c75066b97ff1adca623d37 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur <eldy@destailleur.fr> Date: Thu, 5 Mar 2015 13:51:29 +0100 Subject: [PATCH] Fix bad update of denormalized field --- htdocs/projet/class/task.class.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/projet/class/task.class.php b/htdocs/projet/class/task.class.php index 017e2b782ec..b01a9644cb1 100644 --- a/htdocs/projet/class/task.class.php +++ b/htdocs/projet/class/task.class.php @@ -807,7 +807,7 @@ class Task extends CommonObject if ($ret >= 0) { $sql = "UPDATE ".MAIN_DB_PREFIX."projet_task"; - $sql.= " SET duration_effective = duration_effective + '".price2num($this->timespent_duration)."'"; + $sql.= " SET duration_effective = (SELECT SUM(task_duration) FROM ".MAIN_DB_PREFIX."projet_task_time as ptt where ptt.fk_task = ".$this->id.")"; if (isset($this->progress)) $sql.= ", progress = " . $this->progress; // Do not overwrite value if not provided $sql.= " WHERE rowid = ".$this->id; @@ -980,7 +980,7 @@ class Task extends CommonObject $newDuration = $this->timespent_duration - $this->timespent_old_duration; $sql = "UPDATE ".MAIN_DB_PREFIX."projet_task"; - $sql.= " SET duration_effective = duration_effective + '".$newDuration."'"; + $sql.= " SET duration_effective = (SELECT SUM(task_duration) FROM ".MAIN_DB_PREFIX."projet_task_time as ptt where ptt.fk_task = ".$this->id.")"; $sql.= " WHERE rowid = ".$this->id; dol_syslog(get_class($this)."::updateTimeSpent", LOG_DEBUG); -- GitLab