From 5a4540f2772b92d59ca1fbe88ef1bb54e0f7248e Mon Sep 17 00:00:00 2001 From: tkostuch Date: Mon, 17 Feb 2020 11:14:09 +0100 Subject: [PATCH 1/2] disable mapFallbackUrl by default --- config/default.json | 1 + core/modules/url/store/actions.ts | 11 +++++++++-- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/config/default.json b/config/default.json index 281ca5e297..209176db3b 100644 --- a/config/default.json +++ b/config/default.json @@ -563,6 +563,7 @@ } }, "urlModule": { + "enableMapFallbackUrl": false, "endpoint": "/api/url", "map_endpoint": "/api/url/map" } diff --git a/core/modules/url/store/actions.ts b/core/modules/url/store/actions.ts index a4fba7ac0e..a53b504a7e 100644 --- a/core/modules/url/store/actions.ts +++ b/core/modules/url/store/actions.ts @@ -60,7 +60,8 @@ export const actions: ActionTree = { if (routeData !== null) { return resolve(parametrizeRouteData(routeData, query, storeCodeInPath)) } else { - dispatch('mapFallbackUrl', { url, params: parsedQuery }).then(mappedFallback => { + const mappingActionName = config.urlModule.enableMapFallbackUrl ? 'mapFallbackUrl' : 'mappingFallback' + dispatch(mappingActionName, { url, params: parsedQuery }).then(mappedFallback => { const routeData = getFallbackRouteData({ mappedFallback, url }) dispatch('registerMapping', { url, routeData }) // register mapping for further usage resolve(parametrizeRouteData(routeData, query, storeCodeInPath)) @@ -75,7 +76,10 @@ export const actions: ActionTree = { * This method could be overriden in custom module to provide custom URL mapping logic */ async mappingFallback ({ dispatch }, { url, params }: { url: string, params: any}) { - console.warn('Deprecated action mappingFallback - use mapFallbackUrl instead') + console.warn(` + Deprecated action mappingFallback - use mapFallbackUrl instead. + You can enable mapFallbackUrl by changing 'config.urlModule.enableMapFallbackUrl' to true + `) const { storeCode, appendStoreCode } = currentStoreView() const productQuery = new SearchQuery() url = (removeStoreCodeFromRoute(url.startsWith('/') ? url.slice(1) : url) as string) @@ -152,6 +156,9 @@ export const actions: ActionTree = { }) } ) + if (!response.ok) { + return null + } response = await response.json() return response } catch (err) { From c3d5dbbb1e188ab001e3db159e92775b826bd780 Mon Sep 17 00:00:00 2001 From: tkostuch Date: Mon, 17 Feb 2020 11:19:55 +0100 Subject: [PATCH 2/2] udpate changelog --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 614beacb0c..a904cc6dd0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -44,6 +44,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Optimized attributes loading - @andrzejewsky (#3948) - Improve typescript support for test utils - @resubaka (#4067) - Removed `product/loadConfigurableAttributes` calls - @andrzejewsky, @gibkigonzo (#3336) +- Disable `mapFallback` url by default - @gibkigonzo(#4092) ## [1.11.1] - 2020.02.05