From 4214bf4814241564bb53bec992b9cc7985a82d9e Mon Sep 17 00:00:00 2001 From: Gemini Date: Tue, 30 Jun 2026 16:10:38 -0300 Subject: [PATCH] =?UTF-8?q?fix:=20lan=C3=A7amento=20de=20tempo=20com=20com?= =?UTF-8?q?ent=C3=A1rio-fallback=20(campo=20obrigat=C3=B3rio=20no=20Redmin?= =?UTF-8?q?e)=20(1.5.4)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-Authored-By: Claude Opus 4.8 --- CHANGELOG.md | 11 +++++++++++ hook.php | 8 +++++++- setup.php | 2 +- 3 files changed, 19 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6560193..513124b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,17 @@ Todas as mudanças relevantes deste plugin são documentadas aqui. O formato segue [Keep a Changelog](https://keepachangelog.com/pt-BR/1.0.0/) e o versionamento segue [SemVer](https://semver.org/lang/pt-BR/). +## [1.5.4] + +### Corrigido +- Lançamento de tempo: o campo **comentário** é obrigatório em algumas configs do + Redmine. Se a tarefa do GLPI não tiver descrição, o plugin agora envia um + comentário padrão ("Tempo lançado via GLPI (chamado #N)") em vez de vazio. + +### Notas +- A **Atividade** do lançamento de tempo é **por projeto** no Redmine: a atividade + configurada como padrão precisa estar habilitada no projeto vinculado. + ## [1.5.3] ### Corrigido diff --git a/hook.php b/hook.php index b3c0dca..273789f 100644 --- a/hook.php +++ b/hook.php @@ -416,6 +416,12 @@ function _plugin_redmine_process_tickettask(TicketTask $task) { $cfg = PluginRedmineConfig::getConfigRow(); $hours = round($task->fields['actiontime'] / HOUR_TIMESTAMP, 2); + // Comments are mandatory on time entries in some Redmine setups — never send empty. + $comments = trim(strip_tags(html_entity_decode((string) ($task->fields['content'] ?? '')))); + if ($comments === '') { + $comments = "Tempo lançado via GLPI (chamado #{$ticketId})"; + } + // Time entry author = the GLPI user who logged the task, via impersonation. $taskUserId = (int) ($task->fields['users_id'] ?? 0); $timeSwitchUser = _plugin_redmine_impersonation_login($taskUserId, $redmineProjectId); @@ -423,7 +429,7 @@ function _plugin_redmine_process_tickettask(TicketTask $task) { $timeEntryId = PluginRedmineRedmineapi::logTime( $issueId, $hours, - strip_tags(html_entity_decode($task->fields['content'])), + $comments, !empty($cfg['default_activity_id']) ? (int) $cfg['default_activity_id'] : null, $timeSwitchUser ); diff --git a/setup.php b/setup.php index f2e775f..91bdb19 100644 --- a/setup.php +++ b/setup.php @@ -1,6 +1,6 @@