kirby-logger icon indicating copy to clipboard operation
kirby-logger copied to clipboard

Error when logging out

Open S1SYPHOS opened this issue 3 years ago • 6 comments

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

S1SYPHOS avatar Mar 08 '22 15:03 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!

S1SYPHOS avatar Mar 08 '22 15:03 S1SYPHOS

Go for it 👌 Thank you

michnhokn avatar May 22 '22 09:05 michnhokn

I'll open up a PR and let you know 🦊

S1SYPHOS avatar May 22 '22 15:05 S1SYPHOS

I get the same error, even when I try to reorder images for example.

dwd0tcom avatar Jun 14 '22 12:06 dwd0tcom

I should really send this PR 😀

S1SYPHOS avatar Jun 14 '22 14:06 S1SYPHOS

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());
    }

WA-MB avatar Feb 23 '23 07:02 WA-MB