kirby-logger
kirby-logger copied to clipboard
Error when logging out
Hey there,
when logging out, I get this message: Call to a member function email() on null. Commenting out Line 159 inside classes/Logger.php makes this error go away, see https://github.com/michnhokn/kirby3-logger/blob/main/classes/Logger.php#L159
Cheers, S1SYPHOS
// Update:
Since $event stores the current user, I'm able to mitigate the problem like so:
# Lines 156 - 161
$log = new Log([
'type' => $event->type(),
'action' => $event->action(),
'user' => $event->user()->email(),
'language' => kirby()->languageCode(),
]);
Let me know if you'd be willing to merge a PR and I'll whip one up right away!
Go for it 👌 Thank you
I'll open up a PR and let you know 🦊
I get the same error, even when I try to reorder images for example.
I should really send this PR 😀
my solution
/**
* @param Event $event
*/
public static function log(Event $event): void
{
if (!in_array($event->type(), self::TYPES) || $event->action() === 'render') {
return;
}
$log = self::getLog($event);
self::$connection->table('logs')->insert($log->toArray());
}