Fix PHP warnings: E_STRICT deprecation and "Array" in the ticket timeline (#130) #133

Merged
jared merged 1 commits from php-warnings-130 into development 2026-11-28 23:37:44 -05:00
2 changed files with 35 additions and 13 deletions

No files matched your search

-1
View File
@@ -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',
+35 -12
View File
@@ -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[] = '<strong>' . htmlspecialchars($label) . ':</strong> '
. '<span class="lt-text-muted">' . htmlspecialchars($from) . '</span>'
. '<span class="lt-text-muted">' . htmlspecialchars(formatAuditValue($v['from'])) . '</span>'
. ' <span class="lt-text-amber">→</span> '
. '<span class="lt-text-cyan">' . htmlspecialchars($to) . '</span>';
. '<span class="lt-text-cyan">' . htmlspecialchars(formatAuditValue($v['to'])) . '</span>';
} elseif (!in_array($k, ['old_value', 'new_value'], true)) {
$parts[] = '<strong>' . htmlspecialchars($k) . ':</strong> ' . htmlspecialchars((string)$v);
$parts[] = '<strong>' . htmlspecialchars((string)$k) . ':</strong> '
. htmlspecialchars(formatAuditValue($v, 500));
}
}
if ($parts) {