Skip to content

Commit 6d7b617

Browse files
author
Dolicraft
committed
Fix Dolibarr#35086 do not show TicketMarkedAsClosed when close() failed
Ticket::close() returns >0 on success, 0 on no-op, <0 on error (including when a custom TICKET_CLOSE trigger blocks the close). Two action handlers in ticket/card.php relied on PHP's truthiness, so a returned -1 was treated as success, showing the green TicketMarkedAsClosed message together with the trigger's error. Check >0 explicitly in both confirm_close/confirm_abandon and confirm_public_close. Signed-off-by: Dolicraft <contact@dolicraft.com>
1 parent 13f21da commit 6d7b617

1 file changed

Lines changed: 9 additions & 7 deletions

File tree

htdocs/ticket/card.php

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -461,7 +461,7 @@
461461
$object->context['contact_id'] = GETPOSTINT('contactid');
462462
}
463463

464-
if ($object->close($user, ($action == "confirm_abandon" ? 1 : 0))) { // Test on pemrission already done
464+
if ($object->close($user, ($action == "confirm_abandon" ? 1 : 0)) > 0) { // Test on pemrission already done
465465
setEventMessages($langs->trans('TicketMarkedAsClosed'), null, 'mesgs');
466466

467467
$url = 'card.php?track_id=' . GETPOST('track_id', 'alpha');
@@ -478,13 +478,15 @@
478478
if ($_SESSION['email_customer'] == $object->origin_email || $_SESSION['email_customer'] == $object->thirdparty->email) {
479479
$object->context['contact_id'] = GETPOSTINT('contactid');
480480

481-
$object->close($user);
481+
if ($object->close($user) > 0) {
482+
setEventMessages('<div class="confirm">' . $langs->trans('TicketMarkedAsClosed') . '</div>', null, 'mesgs');
482483

483-
setEventMessages('<div class="confirm">' . $langs->trans('TicketMarkedAsClosed') . '</div>', null, 'mesgs');
484-
485-
$url = 'card.php?track_id=' . GETPOST('track_id', 'alpha');
486-
header("Location: " . $url);
487-
exit;
484+
$url = 'card.php?track_id=' . GETPOST('track_id', 'alpha');
485+
header("Location: " . $url);
486+
exit;
487+
}
488+
setEventMessages($object->error, $object->errors, 'errors');
489+
$action = '';
488490
} else {
489491
setEventMessages($object->error, $object->errors, 'errors');
490492
$action = '';

0 commit comments

Comments
 (0)