fix(clickhouse): use isset() instead of array_key_exists() for Log object in createBatch#123
Conversation
…ject in createBatch
Greptile SummaryThis PR fixes a
Confidence Score: 5/5Safe to merge — the change is a single-line, targeted fix that eliminates the TypeError without altering any other logic. The change is minimal and correct. isset() works for both plain arrays and ArrayAccess objects, resolving the TypeError while preserving the intent of skipping null legacy values (explicitly called out as acceptable in the PR description). The $logData block correctly retains array_key_exists since it operates on a guaranteed plain PHP array. No files require special attention. Important Files Changed
Reviews (1): Last reviewed commit: "fix(clickhouse): use isset() instead of ..." | Re-trigger Greptile |
Summary
The legacy-translation block added in #122 (2.4.0) calls
\array_key_exists($legacy, $log)on each$login the batch. When callers passUtopia\Audit\Log(an ArrayAccess subclass ofDocument) — as Appwrite Cloud's Activity worker does viagetClickHouseAdapter()->createBatch([new Log(...), ...])— PHP 8 throws:The whole batch insert then fails (caught silently downstream), so no rows land in ClickHouse.
isset($log[$key])does the same intent here (only false for absent or null values, and null userId/userType/userInternalId is never meaningful in this code path) and works for both plain arrays and ArrayAccess objects.Test plan
createBatch([new Log(['actorId' => '...', 'actorType' => '...', ...])])no longer throws TypeError