fix: recria issue se a vinculada foi apagada no Redmine (vínculo órfão) (1.5.5)
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
parent
4214bf4814
commit
913fd82272
4 changed files with 29 additions and 3 deletions
|
|
@ -4,6 +4,13 @@ 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/)
|
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/).
|
e o versionamento segue [SemVer](https://semver.org/lang/pt-BR/).
|
||||||
|
|
||||||
|
## [1.5.5]
|
||||||
|
|
||||||
|
### Corrigido
|
||||||
|
- Se a issue Redmine vinculada a um chamado foi **apagada** no Redmine, o plugin
|
||||||
|
reusava o ID órfão e falhava ("Tarefa não é válido"). Agora ele verifica se a
|
||||||
|
issue ainda existe; se não, remove o vínculo órfão e **recria** a issue.
|
||||||
|
|
||||||
## [1.5.4]
|
## [1.5.4]
|
||||||
|
|
||||||
### Corrigido
|
### Corrigido
|
||||||
|
|
|
||||||
11
hook.php
11
hook.php
|
|
@ -366,8 +366,17 @@ function _plugin_redmine_process_tickettask(TicketTask $task) {
|
||||||
'WHERE' => ['tickets_id' => $ticketId]
|
'WHERE' => ['tickets_id' => $ticketId]
|
||||||
]);
|
]);
|
||||||
if (count($issueMap) > 0) {
|
if (count($issueMap) > 0) {
|
||||||
$issueId = (int) $issueMap->current()['redmine_issue_id'];
|
$candidate = (int) $issueMap->current()['redmine_issue_id'];
|
||||||
|
if (PluginRedmineRedmineapi::issueExists($candidate)) {
|
||||||
|
$issueId = $candidate;
|
||||||
} else {
|
} else {
|
||||||
|
// A issue foi apagada no Redmine: remove o vínculo órfão e recria.
|
||||||
|
Toolbox::logInFile('redmine', "Issue #{$candidate} do ticket #{$ticketId} não existe mais; recriando.\n");
|
||||||
|
$DB->delete('glpi_plugin_redmine_tickets', ['tickets_id' => $ticketId]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!$issueId) {
|
||||||
// Build the issue from the ticket + the configured defaults.
|
// Build the issue from the ticket + the configured defaults.
|
||||||
$cfg = PluginRedmineConfig::getConfigRow();
|
$cfg = PluginRedmineConfig::getConfigRow();
|
||||||
$extra = [];
|
$extra = [];
|
||||||
|
|
|
||||||
|
|
@ -257,6 +257,16 @@ class PluginRedmineRedmineapi {
|
||||||
return ($result && isset($result['issue_categories'])) ? $result['issue_categories'] : [];
|
return ($result && isset($result['issue_categories'])) ? $result['issue_categories'] : [];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Whether a Redmine issue still exists (returns false if it was deleted).
|
||||||
|
* @param int $issueId
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
|
public static function issueExists($issueId) {
|
||||||
|
$result = self::get("/issues/{$issueId}.json");
|
||||||
|
return $result && isset($result['issue']['id']);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get all Redmine users (paginated). Requires admin API key.
|
* Get all Redmine users (paginated). Requires admin API key.
|
||||||
* @return array
|
* @return array
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
define('PLUGIN_REDMINE_VERSION', '1.5.4');
|
define('PLUGIN_REDMINE_VERSION', '1.5.5');
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Load the Mindplace License class if the autoloader has not run yet.
|
* Load the Mindplace License class if the autoloader has not run yet.
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue