From 1ea7af6435a6bb0a83267c927a6a9a96c8500bf9 Mon Sep 17 00:00:00 2001 From: Gemini Date: Mon, 29 Jun 2026 23:26:04 -0300 Subject: [PATCH] =?UTF-8?q?fix:=20compat=20GLPI=2011.0.4=20=E2=80=94=20rem?= =?UTF-8?q?ove=20macro=20csrfField=20do=20form=20de=20config=20(1.5.1)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - config_form usava fields.csrfField() (inexistente no 11.0.4) -> erro fatal - token CSRF agora via csrf_token_value (PHP); URL usa textField - compatível com 11.0.0+ Co-Authored-By: Claude Opus 4.8 --- CHANGELOG.md | 8 ++++++++ inc/config.class.php | 1 + setup.php | 2 +- templates/config_form.html.twig | 8 ++++---- 4 files changed, 14 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 501fb2e..538589e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,14 @@ 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.1] + +### Corrigido +- Compatibilidade com GLPI 11.0.4: o formulário de configuração usava o macro + `fields.csrfField()` (só existe a partir de versões mais novas), causando + `Macro "csrfField" is not defined`. Agora o token CSRF é emitido via + `csrf_token_value` (PHP), e o campo de URL usa `textField` — compatível com 11.0.0+. + ## [1.5.0] ### Adicionado diff --git a/inc/config.class.php b/inc/config.class.php index 0594726..05c4e72 100644 --- a/inc/config.class.php +++ b/inc/config.class.php @@ -182,6 +182,7 @@ class PluginRedmineConfig extends CommonDBTM { \Glpi\Application\View\TemplateRenderer::getInstance()->display('@redmine/config_form.html.twig', [ 'action_url' => Toolbox::getItemTypeFormURL(__CLASS__), + 'csrf_token_value' => Session::getNewCSRFToken(), 'redmine_url' => $config['redmine_url'] ?? '', 'has_key' => !empty($config['api_key']), 'has_metadata' => !empty($metadata['trackers']) || !empty($metadata['statuses']), diff --git a/setup.php b/setup.php index 2bf207d..de8127d 100644 --- a/setup.php +++ b/setup.php @@ -1,6 +1,6 @@ - {{ fields.csrfField() }} + {# --- Conexão --- #} @@ -16,7 +16,7 @@
- {{ fields.urlField('redmine_url', redmine_url, __('URL do Redmine', 'redmine'), { + {{ fields.textField('redmine_url', redmine_url, __('URL do Redmine', 'redmine'), { 'helper': 'https://redmine.exemplo.com.br' }) }} {{ fields.passwordField('api_key', '', __('Chave de API (Admin)', 'redmine'), { @@ -108,7 +108,7 @@ {{ m.redmine_name }}
- {{ fields.csrfField() }} +
@@ -121,7 +121,7 @@
- {{ fields.csrfField() }} +
{{ fields.dropdownField('User', 'override_users_id', 0, __('Usuário GLPI', 'redmine'), {'display_emptychoice': true}) }}