Skip to content

Commit

Permalink
fix #9
Browse files Browse the repository at this point in the history
  • Loading branch information
matfish3 committed Jun 18, 2023
1 parent 661f900 commit 3be332c
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions src/services/RecordRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,9 @@ public function record(): void

$model = new ActivityLogModel([
'userId' => Craft::$app->user->id ?? null,
'url' => iconv('ISO-8859-1', 'UTF-8', $ps[0]),
'query' => $query ? iconv('ISO-8859-1', 'UTF-8', json_encode($query, JSON_THROW_ON_ERROR)) : null,
'payload' => iconv('ISO-8859-1', 'UTF-8', $payload),
'url' => $ps[0],
'query' => $query ? json_encode($query, JSON_THROW_ON_ERROR) : null,
'payload' => $payload,
'isAjax' => $this->isAjax(),
'method' => $req->getMethod(),
'ip' => $req->getUserIP(),
Expand All @@ -76,7 +76,12 @@ public function record(): void
$record->actionSegments = $model->actionSegments;
$record->createdAt = Carbon::now();

$record->save();
try {
$record->save();
} catch (\Exception $e) { // Fix https://github.com/matfish2/craft-activity-log/issues/9
$record->url = iconv('iso-8859-1', 'utf-8', $record->url);
$record->save();
}

$start = microtime(true);

Expand Down

0 comments on commit 3be332c

Please sign in to comment.