Skip to content

[Backward compatibility] Customer section load with one section causes an error #28154

Closed
@zhartaunik

Description

@zhartaunik

Preconditions (*)

  1. Magento 2.4-develop
  2. It cannot be reproduced on clean Magento. An issue occurred only with incompatible code.

Steps to reproduce (*)

Open any page and take any action which force Magento to clean one section (In my case it was adding product to shopping cart from PDP)
Source code should contain sth like
customerData.reload('cart');
instead of
customerData.reload(['cart']);

Expected result (*)

The console log must be clear.

Actual result (*)

We faced with an issue in console:
customer-data.js:87 Uncaught Error: [object Object]
at Object. (customer-data.js:87)
at fire (jquery.js:3238)
at Object.fireWith [as rejectWith] (jquery.js:3368)
at done (jquery.js:9848)
at XMLHttpRequest.callback (jquery.js:10317)

Screenshot from 2020-09-16 14-42-31

What actually happens:

www/magento/vendor/magento/module-customer/view/frontend/web/js/section-config.js:61
Previous code:

        /**
         * @param {*} allSections
         * @return {*}
         */
        filterClientSideSections: function (allSections) {
            if (Array.isArray(allSections)) {
                return _.difference(allSections, clientSideSections);
            }

            return allSections;
        },

Magento 2.3.5-p1 code:

        /**
         * Filters the list of given sections to the ones defined as client side.
         * @param {Array} allSections - List of sections to check.
         * @return {Array} - List of filtered sections.
         */
        filterClientSideSections: function (allSections) {
            return _.difference(_.toArray(allSections), clientSideSections);
        },

When we pass into this function one element (string) JS parses as an array:

_.toArray(allSections)
(9) ["a", "u", "t", "h", "_", "d", "a", "t", "a"]

And of course cannot find such sections.

Upd 1.
Initially, your method accepted anything and we passed a string with a section name. Now your are accepting arrays only, but there no such verification in the method.
I suppose for backward compatibility you should return back isArray verification.

Metadata

Metadata

Assignees

Labels

Component: CustomerComponent: MultishippingFixed in 2.4.xThe issue has been fixed in 2.4-develop branchIssue: ConfirmedGate 3 Passed. Manual verification of the issue completed. Issue is confirmedIssue: Format is validGate 1 Passed. Automatic verification of issue format passedIssue: Ready for WorkGate 4. Acknowledged. Issue is added to backlog and ready for developmentPriority: P3May be fixed according to the position in the backlog.Progress: doneReported on 2.3.5-p1Indicates original Magento version for the Issue report.Reproduced on 2.4.xThe issue has been reproduced on latest 2.4-develop branchSeverity: S3Affects non-critical data or functionality and does not force users to employ a workaround.

Type

No type

Projects

Status

Done

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions