From 4c597d650b6e5b99a04233d97190b6c20b1a57af Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Charl=C3=A8ne=20Benke?= <1179011+defrance@users.noreply.github.com> Date: Wed, 3 Dec 2025 07:40:57 +0100 Subject: [PATCH 1/2] Update addTimeSpent api method to use default progress with null parameters, swagger validator fail --- htdocs/projet/class/api_tasks.class.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/htdocs/projet/class/api_tasks.class.php b/htdocs/projet/class/api_tasks.class.php index 4bf54b81b03..acc112844de 100644 --- a/htdocs/projet/class/api_tasks.class.php +++ b/htdocs/projet/class/api_tasks.class.php @@ -4,6 +4,7 @@ * Copyright (C) 2024-2025 Frédéric France * Copyright (C) 2025 MDW * Copyright (C) 2025 Jessica Kowal + * Copyright (C) 2025 Charlene Benke * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -623,7 +624,7 @@ class Tasks extends DolibarrApi * @phan-return array{success:array{code:int,message:string}} * @phpstan-return array{success:array{code:int,message:string}} */ - public function addTimeSpent($id, $date, $duration, $product_id = null, $user_id = 0, $note = '', $progress = null) + public function addTimeSpent($id, $date, $duration, $product_id = null, $user_id = 0, $note = '', $progress = -1) { if (!DolibarrApiAccess::$user->hasRight('projet', 'creer')) { throw new RestException(403); @@ -651,7 +652,7 @@ class Tasks extends DolibarrApi $this->task->timespent_fk_product = $product_id; $this->task->timespent_fk_user = $uid; $this->task->timespent_note = $note; - if (!empty($this->task->progress)) + if (!empty($progress) && $progress >= 0 && $progress <= 100) { $this->task->progress = $progress; $result = $this->task->addTimeSpent(DolibarrApiAccess::$user, 0); From 656255eecd5dbf61d44950dc59f038700410a685 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Charl=C3=A8ne=20Benke?= <1179011+defrance@users.noreply.github.com> Date: Wed, 3 Dec 2025 13:03:09 +0100 Subject: [PATCH 2/2] Fix progress assignment in addTimeSpent method --- htdocs/projet/class/api_tasks.class.php | 1 + 1 file changed, 1 insertion(+) diff --git a/htdocs/projet/class/api_tasks.class.php b/htdocs/projet/class/api_tasks.class.php index acc112844de..6cc0df8f3ed 100644 --- a/htdocs/projet/class/api_tasks.class.php +++ b/htdocs/projet/class/api_tasks.class.php @@ -654,6 +654,7 @@ class Tasks extends DolibarrApi $this->task->timespent_note = $note; if (!empty($progress) && $progress >= 0 && $progress <= 100) { $this->task->progress = $progress; + } $result = $this->task->addTimeSpent(DolibarrApiAccess::$user, 0); if ($result == 0) {