diff --git a/helpers/ErrorHandler.php b/helpers/ErrorHandler.php index d05cd2b..8240224 100644 --- a/helpers/ErrorHandler.php +++ b/helpers/ErrorHandler.php @@ -267,7 +267,6 @@ class ErrorHandler E_USER_ERROR => 'USER_ERROR', E_USER_WARNING => 'USER_WARNING', E_USER_NOTICE => 'USER_NOTICE', - E_STRICT => 'STRICT', E_RECOVERABLE_ERROR => 'RECOVERABLE_ERROR', E_DEPRECATED => 'DEPRECATED', E_USER_DEPRECATED => 'USER_DEPRECATED', diff --git a/views/TicketView.php b/views/TicketView.php index f0d352e..18bed4c 100644 --- a/views/TicketView.php +++ b/views/TicketView.php @@ -38,6 +38,34 @@ function getEventIcon(string $actionType): string }; } +/** + * Whether an audit detail is a {from, to} change. array_key_exists, not + * isset: a field set for the first time has from = null (#130). + */ +function isAuditDelta(mixed $v): bool +{ + return is_array($v) && array_key_exists('from', $v) && array_key_exists('to', $v); +} + +/** + * Plain-text form of one audit value for the timeline (the caller escapes + * it): null or '' as "(none)", arrays as JSON, long values cut at $max. + */ +function formatAuditValue(mixed $v, int $max = 60): string +{ + if ($v === null || $v === '') { + return '(none)'; + } + if (is_bool($v)) { + return $v ? 'yes' : 'no'; + } + if (is_array($v) || is_object($v)) { + $v = (string)json_encode($v, JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE); + } + $v = (string)$v; + return mb_strlen($v) > $max ? mb_substr($v, 0, $max) . '…' : $v; +} + function formatAction(array $event): string { $det = $event['details'] ?? []; @@ -72,7 +100,7 @@ function formatAction(array $event): string return 'changed the status'; case 'update': if (is_array($det)) { - $fields = array_keys(array_filter($det, fn($v) => is_array($v) && isset($v['from'], $v['to']))); + $fields = array_keys(array_filter($det, 'isAuditDelta')); if ($fields) { return 'updated ' . implode(', ', array_map(fn($f) => str_replace('_', ' ', $f), $fields)); } @@ -796,20 +824,15 @@ document.addEventListener('DOMContentLoaded', function() { if (is_array($det)) { $parts = []; foreach ($det as $k => $v) { - if (is_array($v) && isset($v['from'], $v['to'])) { - $label = ucfirst(str_replace('_', ' ', $k)); - $from = mb_strlen((string)$v['from']) > 60 - ? mb_substr((string)$v['from'], 0, 60) . '…' - : (string)$v['from']; - $to = mb_strlen((string)$v['to']) > 60 - ? mb_substr((string)$v['to'], 0, 60) . '…' - : (string)$v['to']; + if (isAuditDelta($v)) { + $label = ucfirst(str_replace('_', ' ', (string)$k)); $parts[] = '' . htmlspecialchars($label) . ': ' - . '' . htmlspecialchars($from) . '' + . '' . htmlspecialchars(formatAuditValue($v['from'])) . '' . ' → ' - . '' . htmlspecialchars($to) . ''; + . '' . htmlspecialchars(formatAuditValue($v['to'])) . ''; } elseif (!in_array($k, ['old_value', 'new_value'], true)) { - $parts[] = '' . htmlspecialchars($k) . ': ' . htmlspecialchars((string)$v); + $parts[] = '' . htmlspecialchars((string)$k) . ': ' + . htmlspecialchars(formatAuditValue($v, 500)); } } if ($parts) {