From e64104c2b1a58375b0f7b2387eb13968ef6f3a06 Mon Sep 17 00:00:00 2001
From: Denys Rul <drul@magento.com>
Date: Fri, 18 Nov 2016 15:46:10 +0200
Subject: [PATCH] MAGETWO-59322: Incorrect scope filter caching in UI grids

- Rename dataNamespace to dataScope
---
 .../ui_component/product_listing.xml          |  2 +-
 .../Ui/view/base/web/js/grid/data-storage.js  | 24 ++++++++++---------
 2 files changed, 14 insertions(+), 12 deletions(-)

diff --git a/app/code/Magento/Catalog/view/adminhtml/ui_component/product_listing.xml b/app/code/Magento/Catalog/view/adminhtml/ui_component/product_listing.xml
index caca8151ec8..5fab2d04f22 100644
--- a/app/code/Magento/Catalog/view/adminhtml/ui_component/product_listing.xml
+++ b/app/code/Magento/Catalog/view/adminhtml/ui_component/product_listing.xml
@@ -24,7 +24,7 @@
                     <item name="component" xsi:type="string">Magento_Ui/js/grid/provider</item>
                     <item name="update_url" xsi:type="url" path="mui/index/render"/>
                     <item name="storageConfig" xsi:type="array">
-                        <item name="dataNamespace" xsi:type="string">filters.store_id</item>
+                        <item name="dataScope" xsi:type="string">filters.store_id</item>
                     </item>
                 </item>
             </argument>
diff --git a/app/code/Magento/Ui/view/base/web/js/grid/data-storage.js b/app/code/Magento/Ui/view/base/web/js/grid/data-storage.js
index 3d0828b3b1c..b90138a47b8 100644
--- a/app/code/Magento/Ui/view/base/web/js/grid/data-storage.js
+++ b/app/code/Magento/Ui/view/base/web/js/grid/data-storage.js
@@ -20,7 +20,7 @@ define([
                 method: 'GET',
                 dataType: 'json'
             },
-            dataNamespace: '',
+            dataScope: '',
             data: {}
         },
 
@@ -30,14 +30,14 @@ define([
          * @returns {DataStorage} Chainable.
          */
         initConfig: function () {
-            var namespace;
+            var scope;
 
             this._super();
 
-            namespace = this.dataNamespace;
+            scope = this.dataScope;
 
-            if (typeof namespace === 'string') {
-                this.dataNamespace = namespace ? [namespace] : [];
+            if (typeof scope === 'string') {
+                this.dataScope = scope ? [scope] : [];
             }
 
             this._requests = [];
@@ -88,7 +88,7 @@ define([
         getData: function (params, options) {
             var cachedRequest;
 
-            if (this.hasNamespaceChanged(params)) {
+            if (this.hasScopeChanged(params)) {
                 this.clearRequests();
             } else {
                 cachedRequest = this.getRequest(params);
@@ -102,15 +102,15 @@ define([
         },
 
         /**
-         * Tells whether one of the parameters defined in the "dataNamespace" has
+         * Tells whether one of the parameters defined in the "dataScope" has
          * changed since the last request.
          *
          * @param {Object} params - Request parameters.
          * @returns {Boolean}
          */
-        hasNamespaceChanged: function (params) {
+        hasScopeChanged: function (params) {
             var lastRequest = _.last(this._requests),
-                paths,
+                keys,
                 diff;
 
             if (!lastRequest) {
@@ -118,9 +118,11 @@ define([
             }
 
             diff = utils.compare(lastRequest.params, params);
-            paths = _.pluck(diff.changes, 'path').concat(_.keys(diff.containers));
 
-            return _.intersection(this.dataNamespace, paths).length > 0;
+            keys = _.pluck(diff.changes, 'path');
+            keys = keys.concat(Object.keys(diff.containers));
+
+            return _.intersection(this.dataScope, keys).length > 0;
         },
 
         /**
-- 
GitLab