Skip to content

Commit

Permalink
Avoid error on non-array log lines
Browse files Browse the repository at this point in the history
  • Loading branch information
pjcdawkins committed Nov 26, 2024
1 parent 6d5e117 commit 281703f
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions src/Model/ActivityLog/LogItem.php
Original file line number Diff line number Diff line change
Expand Up @@ -78,12 +78,14 @@ public static function multipleFromJsonStreamWithSeal(string $str): array
continue;
}
$data = static::decode($line);
if (! empty($data['seal'])) {
$seal = true;
}
if (isset($data['data']['timestamp'], $data['data']['message'])) {
$id = isset($data['_id']) ? (string) $data['_id'] : '';
$items[] = new static($data['data']['timestamp'], $data['data']['message'], $id);
if (is_array($data)) {
if (! empty($data['seal'])) {
$seal = true;
}
if (isset($data['data']['timestamp'], $data['data']['message'])) {
$id = isset($data['_id']) ? (string) $data['_id'] : '';
$items[] = new static($data['data']['timestamp'], $data['data']['message'], $id);
}
}
}

Expand Down Expand Up @@ -111,7 +113,7 @@ public function getId(): string
return $this->id;
}

private static function decode(string $str): ?array
private static function decode(string $str): mixed
{
$data = json_decode($str, true);
if ($data === null) {
Expand Down

0 comments on commit 281703f

Please sign in to comment.