PHP warnings in prod log: E_STRICT deprecated (ErrorHandler) and "Array to string conversion" in the ticket timeline #130

Closed
opened 2026-11-28 12:46:29 -05:00 by jared · 0 comments
Owner

Two PHP warnings show up in CT132's /var/log/nginx/error.log on prod (PHP-FPM 8.4). Neither breaks a page today.

1. Constant E_STRICT is deprecated in helpers/ErrorHandler.php:270

PHP Deprecated:  Constant E_STRICT is deprecated in /var/www/html/tinkertickets/helpers/ErrorHandler.php on line 270
  • Cause: the error-type name map still lists E_STRICT => 'STRICT'. PHP 8.4 deprecates the E_STRICT constant, because it has had no effect since PHP 8.0. Any request that loads the error handler can log it.
  • Risk: low now. In a future PHP version the constant will be removed, and then the file fails with "Undefined constant".
  • Fix: drop the E_STRICT line. If PHP 8.2/8.3 should still get a name for it, guard it instead: if (defined('E_STRICT') && PHP_VERSION_ID < 80400). Also check whether anything else uses E_STRICT (e.g. in an error_reporting() mask).

2. Array to string conversion in views/TicketView.php:812 (activity timeline)

[WARNING] WARNING: Array to string conversion in /var/www/html/tinkertickets/views/TicketView.php on line 812

Logged since 2026-11-27, about once each time someone opens an affected ticket.

  • Cause: the timeline formats an audit detail as "from → to" only when isset($v['from'], $v['to']). isset() is false when either value is null. Such an entry then falls to the generic branch, htmlspecialchars((string)$v), which logs the warning and shows the literal text "Array" in the timeline.
  • What triggered it: audit rows from #123/#124 where the old value is null:
    • backfill_ticket_source.php: source: {from: null, to: "hwmonDaemon"}, on 147 tickets (137 hwmonDaemon, 10 gandalf), written 2026-11-25.
    • backfill_dedup_keys.php: dedup_key: {from: null, to: ...}, for any ticket backfilled later.
  • Any other audit detail whose value is an array without both keys hits the same branch.
  • Fix:
    • Test with array_key_exists instead of isset (is_array($v) && array_key_exists('from', $v) && array_key_exists('to', $v)), and show null as "(none)".
    • Give the generic branch a fallback for arrays (e.g. json_encode) instead of (string), so an unexpected shape never prints "Array".

How to check after the fix

  • Open one of the backfilled tickets, e.g. 703260823. The timeline should read Source: (none) → hwmonDaemon with no new log line.
  • Then:
    grep -c "E_STRICT\|Array to string" /var/log/nginx/error.log
    
    It should stop growing.

🤖 Generated with Claude Code

Two PHP warnings show up in CT132's `/var/log/nginx/error.log` on prod (PHP-FPM 8.4). Neither breaks a page today. ## 1. `Constant E_STRICT is deprecated` in `helpers/ErrorHandler.php:270` ``` PHP Deprecated: Constant E_STRICT is deprecated in /var/www/html/tinkertickets/helpers/ErrorHandler.php on line 270 ``` - **Cause:** the error-type name map still lists `E_STRICT => 'STRICT'`. PHP 8.4 deprecates the `E_STRICT` constant, because it has had no effect since PHP 8.0. Any request that loads the error handler can log it. - **Risk:** low now. In a future PHP version the constant will be removed, and then the file fails with "Undefined constant". - **Fix:** drop the `E_STRICT` line. If PHP 8.2/8.3 should still get a name for it, guard it instead: `if (defined('E_STRICT') && PHP_VERSION_ID < 80400)`. Also check whether anything else uses `E_STRICT` (e.g. in an `error_reporting()` mask). ## 2. `Array to string conversion` in `views/TicketView.php:812` (activity timeline) ``` [WARNING] WARNING: Array to string conversion in /var/www/html/tinkertickets/views/TicketView.php on line 812 ``` Logged since 2026-11-27, about once each time someone opens an affected ticket. - **Cause:** the timeline formats an audit detail as "from → to" only when `isset($v['from'], $v['to'])`. `isset()` is false when either value is `null`. Such an entry then falls to the generic branch, `htmlspecialchars((string)$v)`, which logs the warning and **shows the literal text "Array"** in the timeline. - **What triggered it:** audit rows from #123/#124 where the old value is `null`: - `backfill_ticket_source.php`: `source: {from: null, to: "hwmonDaemon"}`, on **147 tickets** (137 hwmonDaemon, 10 gandalf), written 2026-11-25. - `backfill_dedup_keys.php`: `dedup_key: {from: null, to: ...}`, for any ticket backfilled later. - Any other audit detail whose value is an array without both keys hits the same branch. - **Fix:** - Test with `array_key_exists` instead of `isset` (`is_array($v) && array_key_exists('from', $v) && array_key_exists('to', $v)`), and show `null` as "(none)". - Give the generic branch a fallback for arrays (e.g. `json_encode`) instead of `(string)`, so an unexpected shape never prints "Array". ## How to check after the fix - Open one of the backfilled tickets, e.g. 703260823. The timeline should read `Source: (none) → hwmonDaemon` with no new log line. - Then: ``` grep -c "E_STRICT\|Array to string" /var/log/nginx/error.log ``` It should stop growing. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
jared closed this issue 2026-11-28 23:37:45 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: LotusGuild/tinker_tickets#130