Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error when logging out #2

Open
S1SYPHOS opened this issue Mar 8, 2022 · 6 comments
Open

Error when logging out #2

S1SYPHOS opened this issue Mar 8, 2022 · 6 comments
Labels
bug Something isn't working

Comments

@S1SYPHOS
Copy link

S1SYPHOS commented Mar 8, 2022

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
Copy link
Author

S1SYPHOS commented Mar 8, 2022

// 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!

@michnhokn
Copy link
Owner

Go for it 👌 Thank you

@michnhokn michnhokn added the bug Something isn't working label May 22, 2022
@S1SYPHOS
Copy link
Author

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

@dwd0tcom
Copy link

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

@S1SYPHOS
Copy link
Author

I should really send this PR 😀

@WA-MB
Copy link

WA-MB commented Feb 23, 2023

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants