Skip to content

Commit

Permalink
fix(issue): handle deletion of validation
Browse files Browse the repository at this point in the history
Signed-off-by: Thierry Bugier <[email protected]>
  • Loading branch information
btry committed Oct 20, 2020
1 parent ca68eb4 commit 385eee4
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 4 deletions.
4 changes: 4 additions & 0 deletions hook.php
Original file line number Diff line number Diff line change
Expand Up @@ -467,6 +467,10 @@ function plugin_formcreator_hook_update_ticketvalidation(CommonDBTM $item) {
$issue->update(['status' => $status['status']] + $issue->fields);
}

function plugin_formcreator_hook_purge_ticketvalidation(CommonDBTM $item) {
plugin_formcreator_hook_update_ticketvalidation($item);
}

function plugin_formcreator_dynamicReport($params) {
switch ($params['item_type']) {
case PluginFormcreatorFormAnswer::class;
Expand Down
15 changes: 11 additions & 4 deletions inc/common.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -230,16 +230,23 @@ public static function cancelMyTicket($id) {
* t s | CLOSED | T V T T
*
* T = status picked from Ticket
* V = status picked ce qfrom Validation
* V = status picked from Validation
*
* @param Ticket $item
* @return integer
*/
public static function getTicketStatusForIssue(Ticket $item) {
$ticketValidation = new TicketValidation();
$ticketValidation->getFromDBByCrit([
$ticketValidations = (new TicketValidation())->find([
'tickets_id' => $item->getID(),
]);
], [
'timeline_position ASC'
], 1);
$ticketValidation = new TicketValidation();
if (count($ticketValidations)) {
$row = array_shift($ticketValidation);
$ticketValidation->getFromDB($row['id']);
}

$status = $item->fields['status'];
$user = 0;
if (!$ticketValidation->isNewItem()) {
Expand Down
1 change: 1 addition & 0 deletions inc/issue.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,7 @@ public static function cronSyncIssues(CronTask $task) {
$DB->query("INSERT INTO `$table` SELECT * FROM ($query) as `dt`");
$volume = 1;
}
Toolbox::logError("Plugin Formcreator: Automatic action SyncIssue detected an inconsticency. Issues were rebuilt.");
}
}
$task->setVolume($volume);
Expand Down
3 changes: 3 additions & 0 deletions setup.php
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,9 @@ function plugin_init_formcreator() {
$PLUGIN_HOOKS['item_update']['formcreator'] = [
TicketValidation::class => 'plugin_formcreator_hook_update_ticketvalidation'
];
$PLUGIN_HOOKS['item_purge']['formcreator'] = [
TicketValidation::class => 'plugin_formcreator_hook_purge_ticketvalidation'
];
$PLUGIN_HOOKS['pre_item_purge']['formcreator'] = [
PluginFormcreatorTargetTicket::class => 'plugin_formcreator_hook_pre_purge_targetTicket',
PluginFormcreatorTargetChange::class => 'plugin_formcreator_hook_pre_purge_targetChange'
Expand Down

0 comments on commit 385eee4

Please sign in to comment.