vanilophp / cart

Cart Module for Vanilo (or any Laravel app)
https://vanilo.io
MIT License
50 stars 17 forks source link

Call to a member function getUser() on null #11

Closed Romik90 closed 4 years ago

Romik90 commented 4 years ago

I updated to 1.1 version. After adding some item to cart I tried to log in but encountered following error Screenshot

victorighalo commented 4 years ago

I just hit similar bug : Call to a member function setUser() on null. any quick fix for this cuss it's urgent

victorighalo commented 4 years ago

After over 6 hours the error cleared out. What could be the cause?

victorighalo commented 4 years ago

After over 6 hours the error cleared out. What could be the cause?

I tried to add to cart again but it failed to add to cart then the error came back. How do i even reset it?

fulopattila122 commented 4 years ago

I've seen this on routes without the web middleware. Cart persistence is based on sessions, and it's handled by the web middleware in Laravel.

However I still consider this as a bug in Vanilo cart and will look into in the next days.

preliot commented 4 years ago

Same here. Seems cartmanager > getUser() is called on non existing model.

Although getUser() checks if cart exists (session key), it does not check if this model is really available in DB. I think exists() should also verify that the cart is really in the DB, before getUser() is called on null.

Quickfix 1: delete sessions.

Quickfix 2:

CartManager.php

/**
     * @inheritDoc
     */
    public function exists()
    {
        return (bool) $this->getCartId() && $this->model();
    }
fulopattila122 commented 4 years ago

Update to v1.1.1 for the fixed version composer update vanilo/cart ^1.1.1