magento / magento2

Prior to making any Submission(s), you must sign an Adobe Contributor License Agreement, available here at: https://opensource.adobe.com/cla.html. All Submissions you make to Adobe Inc. and its affiliates, assigns and subsidiaries (collectively “Adobe”) are subject to the terms of the Adobe Contributor License Agreement.
http://www.magento.com
Open Software License 3.0
11.56k stars 9.32k forks source link

Minicart Issue with upgrade 2.1.7-2.1.9 #11375

Closed pioneerathletics closed 7 years ago

pioneerathletics commented 7 years ago

Preconditions

  1. Magento 2.1.9 CE
  2. PHP 7.0.24
  3. Apache/2.4.23 CentOS
  4. Redis enabled
  5. All Caches enabled

Steps to reproduce

  1. Updating from 2.1.7 to 2.1.9
  2. Ran from the CLI– composer require magento/product-community-edition 2.1.9 --no-update composer update
  3. rm -rf /var/cache/ rm -rf /var/page_cache/ rm -rf /var/generation/*
  4. php bin/magento setup:upgrade
  5. php bin/magento setup:di:compile
  6. php bin/magento setup:static-content:deploy
  7. php bin/magento cache:flush and cache/clean
  8. No errors present in terminal

Expected result

  1. Magento should update to 2.1.9 as expected
  2. Should be able to add products to cart

Actual result

  1. Error in knockout.js when trying to add a product to the mini cart
  2. Seems to mainly happen in Google Chrome (current version)
  3. Error in console Uncaught ReferenceError: Unable to process binding "if: function (){return getCartParam('summary_count') }" Message: Unable to process binding "if: function (){return maxItemsToDisplay < getCartLineItemsCount() }" Message: maxItemsToDisplay is not defined at if (eval at createBindingsStringEvaluator (knockout.js:2624), <anonymous>:3:55) at ko.computed.disposeWhenNodeIsRemoved (knockout.js:3989) at evaluateImmediate (knockout.js:1737) at Object.ko.computed.ko.dependentObservable (knockout.js:1946) at init (knockout.js:3988) at knockout.js:2989 at Object.ignore (knockout.js:1249) at knockout.js:2988 at Object.arrayForEach (knockout.js:151) at applyBindingsToNodeInternal (knockout.js:2974)
  4. Error won’t clear out, even when clearing _var/cache/, var/view_preprocessed/, pub/static/*_ and running static-content:deploy again.
  5. Even tried running setup:upgrade and setup:di:compile again but nothing cleared out the error from the browser
  6. Also tried redeploying production mode – magento deploy:mode:set production screen shot 2017-10-07 at 9 57 39 am copy screen shot 2017-10-09 at 1 45 52 pm
orlangur commented 7 years ago

Please make sure your updated https://github.com/magento/magento2/blob/2.1.8/app/code/Magento/Checkout/view/frontend/web/js/view/minicart.js#L81 corresponds to the core version. Can you reproduced on a clean Magento 2.1.9 install? What kind of minicart customizations are made?

pioneerathletics commented 7 years ago

Hi there Vlad, Yes I have confirmed that the linked file you've provided is the same file I have in my system. I do not have any minicart customizations whatsoever. I've only had this issue when upgrading from 2.1.7 to 2.1.9 just within the last week. Interestingly enough I updated another store to 2.1.9 during the week of Sept. 22nd and didn't notice any issues.

When I did update this week, though, I noticed the difference was symfony had several updates that weren't there the week of Sept. 22nd.

Below is Sept. 22nd upgrade to 2.1.9 on a separate store `Updating dependencies (including require-dev) Package operations: 0 installs, 57 updates, 0 removals

And this is the update from this week on October 10th: `Updating dependencies (including require-dev) Package operations: 0 installs, 70 updates, 0 removals

orlangur commented 7 years ago

I don't think composer packages could break it. Just search for "maxItemsToDisplay" all over the 2.1.9 vanilla code and your codebase to check if all of them in place. For example it can be missing in \Magento\Checkout\Block\Cart\Sidebar::getConfig.

pioneerathletics commented 7 years ago

I'm not sure how I can check the entire codebase? How will I know where they are supposed to be?

orlangur commented 7 years ago

In PhpStorm you can do it with Cmd+Shift+F, in terminal with grep -i maxItemsToDisplay.

pioneerathletics commented 7 years ago

I see, I do not have PhpStorm-I'll have to look into it. It seems like the issue is related to this one? #4170

orlangur commented 7 years ago

No, it was a different issue fix: https://github.com/magento/magento2/blame/2.1/app/code/Magento/Checkout/view/frontend/web/js/view/minicart.js#L81

Usually such error may occur if you override some core js component or html template so that after upgrade it does not contain all necessary functionality.

fendowuk commented 7 years ago

We had exactly the same problem yesterday, in the end our host fixed the issue for us. He "chrooted" in and then ran the following commands (altered slightly for non magestack environment).

rm -rf var/generation/* var/view_preprocessed/* pub/static/* php bin/magento deploy:mode:set production php bin/magento cache:flush; curl -X PURGE https://www.example.com/.*

We were in developer mode prior to running the commands and all cache was turned off. We must have ran these commands 20+ times during the day to try to solve the error so we aren't sure if the fact he "chrooted" in could have made the difference, although I think maybe varnish hadn't been purged properly before.

I hope it helps!

pioneerathletics commented 7 years ago

Thanks @fendowuk we'll have to give it a try. Actually I looked back at the exception.log and came across this:[2017-10-06 11:52:23] main.CRITICAL: RuntimeException: Source class "" for "Magento\Framework\App\Response\Http\Interceptor" generation does not exist. in /home/website/web-folder/vendor/magento/framework/Code/Generator.php:185 and also [2017-10-06 11:54:16] main.CRITICAL: ReflectionException: Class Magento\MediaStorage\Model\File\Storage\Response\Interceptor does not exist in /home/website/web-folder/vendor/magento/framework/Code/Reader/ClassReader.php:19 Could it have been just an error in deploying the new version?

fendowuk commented 7 years ago

Hi @pioneerathletics I can't be sure, I think it is more than likely a cache issue. Are you using varnish? I would try enabling developer mode, disabling cache and running the commands above.

pioneerathletics commented 7 years ago

Hi @fendowuk no we're just using the built in cache (I had a lot of problems with disappearing nav menus with varnish). We are also on production mode, do you usually switch over to developer mode when you update?

pioneerathletics commented 7 years ago

Forgot to mention we're using Redis as well.

fendowuk commented 7 years ago

Hi @pioneerathletics I've just always done it, I guess there is no reason to. If you are in production mode just try running.

rm -rf var/generation/* var/view_preprocessed/* pub/static/* php bin/magento setup:di:compile php bin/magento setup:static-content:deploy php bin/magento cache:flush redis-cli flushall

If that doesn't work I'd try to run as root/chroot as it's the only other difference in what I was doing to what my host did.

magento-engcom-team commented 7 years ago

Hi @pioneerathletics Did you help the last comment from fendowuk?

pioneerathletics commented 7 years ago

I haven't tried the suggestion yet. I am waiting until the weekend to attempt the upgrade because the last time I updated my minicart issue started and I was forced to restore from a backup that took our store offline during business hours.

magento-engcom-team commented 7 years ago

@pioneerathletics Thanks for the feedback. Please update after you try last proposal.

xmav commented 7 years ago

I saw same issue after upgrade from 2.1.7 to 2.19 rm -rf var/generation/* var/view_preprocessed/* pub/static/* solved the issue for me (default mode)

pioneerathletics commented 7 years ago

So I tried updating again from 2.1.7 to 2.1.9., in production mode, and yet again I've had the same mini-cart issue. I tried the suggestions from @fendowuk and at first glance they didn't work. I had to manually clear my browser cache in order for the changes to apply (Chrome, Safari, Safari iOs) .

@magento-engcom-team why would this issue still be persistent, except for when I manually cleared my browser cache? It wouldn't be a big deal, but if a repeat customer visits the store again and the mini-cart is not functioning how would they know to clear their browser cache and cookies?

orlangur commented 7 years ago

@pioneerathletics are you able to reproduce this problem on a clean Magento 2.1.7 installation ("clean" in terms of modules/themes, it can contain any data and/or official sample data) when it is upgraded to 2.1.9?

magento-engcom-team commented 7 years ago

Hi @pioneerathletics Are you able to reproduce this problem on a clean Magento 2.1.7 installation ("clean" in terms of modules/themes, it can contain any data and/or official sample data) when it is upgraded to 2.1.9?

fendowuk commented 7 years ago

Hi @pioneerathletics

I also had the same issue with having to clear browser cache before seeing the changes. Sorry, I should have also said that initially.

I have however just realised that the .htaccess file in pub/static/.htaccess was missing. I am wondering if this could have been the cause, do you have that file on your site?

Tristan-N commented 7 years ago

Same issue here. Tried all of the above, still no functioning minicart.

PHP 7.0 and 7.1 Mysql 5.7 Magento CE 2.1.9

Tristan-N commented 7 years ago

I figured out that once created an override for minicart.js and it didn't get updated like @orlangur mentioned

No, it was a different issue fix: https://github.com/magento/magento2/blame/2.1/app/code/Magento/Checkout/view/frontend/web/js/view/minicart.js#L81 Usually such error may occur if you override some core js component or html template so that after upgrade it does not contain all necessary functionality.

I checked the difference between the files (original in vendor folder and custom in app/design) (using diffchecker.com) to see what happened and updated the override.

After that I followed @fendowuk's advice:

We had exactly the same problem yesterday, in the end our host fixed the issue for us. He "chrooted" in and then ran the following commands (altered slightly for non magestack environment).

rm -rf var/generation/ var/view_preprocessed/ pub/static/ php bin/magento deploy:mode:set production php bin/magento cache:flush; curl -X PURGE https://www.example.com/.

We were in developer mode prior to running the commands and all cache was turned off. We must have ran these commands 20+ times during the day to try to solve the error so we aren't sure if the fact he "chrooted" in could have made the difference, although I think maybe varnish hadn't been purged properly before.

I hope it helps!

To finish it all I cleared local browser cache and looked again and guess what? It solved my problem.

So, the only advice I'm missing in here is: go to root folder of Magento in terminal and enter find . -name minicart.js and see if there are customized versions of this file. If so, check if maxItemsToDisplay exists and add it there using https://github.com/magento/magento2/blame/2.1/app/code/Magento/Checkout/view/frontend/web/js/view/minicart.js if needed.

magento-engcom-team commented 7 years ago

@pioneerathletics, we are closing this issue due to inactivity. If you'd like to update it, please reopen the issue.