Magento2: 2.1.9 Item not added to the Wishlist if the user is not logged at the moment he click on the button to add it.

Created on 27 Oct 2017  路  11Comments  路  Source: magento/magento2


Preconditions


  1. Magento 2.1.9 installed

Steps to reproduce

  1. Create an user account.
  2. Logout from the user account
  3. Add a product to your Wishlist , you will get redirected to the login page
  4. Login

Expected result

  1. You are redirected to the customer account Wishlist page and the product is added.

Actual result

  1. You are redirected to the customer account Wishlist page but the product is not added.

Looking at the bug fix "APPSEC-1755: Anti-CSRF form_key is not changed after login" here https://magento.com/security/patches/magento-2016-and-219-security-update , it seems that since the form key is now changed after the login, the form key used for the Wishlist in vendor/magento/module-wishlist/Controller/Index/Add.php does not validate at the beginning of the execute function.

public function execute()
{
    /** @var \Magento\Framework\Controller\Result\Redirect $resultRedirect */
    $resultRedirect = $this->resultFactory->create(ResultFactory::TYPE_REDIRECT);
    if (!$this->formKeyValidator->validate($this->getRequest())) {
        return $resultRedirect->setPath('*/');
    }
Fixed in 2.1.x Fixed in 2.2.x Fixed in 2.3.x Clear Description Confirmed Format is valid Ready for Work Reproduced on 2.1.x Reproduced on 2.2.x Reproduced on 2.3.x

Most helpful comment

All 11 comments

@carloricci84, thank you for your report.
We've created internal ticket(s) MAGETWO-82985 to track progress on the issue.

I am working on it at #mm17es

The issue has been fixed and delivered to 2.1-develop, 2.2-develop and 2.3-develop branches. Will be available with upcoming patch release

Are we sure this is fixed in 2.2.2? I am seeing this exact same bug. If you go through the login form, the form_key changes and when module-wishlist/Controller/Index/Add.php::execute() runs it fails at the $this->formKeyValidator->validate($this->getRequest()) line, just as described.

Hi @thaddeusmt I tested with branch 2.2-develop with sample data and works fine.

This issue will be added to 2.2.4

I am facing issue with magento 2.2.2 wishlist. Item are not added in wishlist if user logged out.
Here are the steps with sample data
Steps to reproduce.

  1. Click on item when user is not logged in
    image
  2. It redirect to login screen.
    image
  3. After login it shows.
    image

There is one more issue in wishlist.
If user have some item in their wishlist it should highlight on that item page/category page, but it not.
image
image
image

Please provide way to solve it.

Hi @lalit-algoworks this issue will be fixed in 2.2.4

Magento support gave us a patch for 2.2.2, so perhaps it will be fixed in 2.2.3+

can you share me the patch

not work, add item wishlist magento 2.3 Invalid Form Key,

Was this page helpful?
0 / 5 - 0 ratings