From 76da828168f593b6a3a578a23bab94687491a2b2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Garc=C3=ADa=20Aubert?= Date: Tue, 16 Jan 2018 17:55:09 +0100 Subject: [PATCH 1/2] Use error label as middleware argument --- lib/cartodb/controllers/named_maps.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/cartodb/controllers/named_maps.js b/lib/cartodb/controllers/named_maps.js index f3aff5bd..5744633a 100644 --- a/lib/cartodb/controllers/named_maps.js +++ b/lib/cartodb/controllers/named_maps.js @@ -46,9 +46,9 @@ NamedMapsController.prototype.register = function(app) { cors(), userMiddleware, this.prepareContext, - this.getNamedMapProvider(), + this.getNamedMapProvider('NAMED_MAP_TILE'), this.getAffectedTables(), - this.getTile(), + this.getTile('NAMED_MAP_TILE'), this.setSurrogateKey(), this.setCacheChannelHeader(), this.setLastModifiedHeader(), @@ -177,7 +177,7 @@ NamedMapsController.prototype.prepareLayerFilterFromPreviewLayers = function (la }.bind(this); }; -NamedMapsController.prototype.getTile = function () { +NamedMapsController.prototype.getTile = function (label) { return function getTileMiddleware (req, res, next) { const { namedMapProvider } = res.locals; @@ -185,7 +185,7 @@ NamedMapsController.prototype.getTile = function () { req.profiler.add(stats); if (err) { - err.label = 'NAMED_MAP_TILE'; + err.label = label; return next(err); } From da32d966071c47c546760ffd788d57769417aa8c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Garc=C3=ADa=20Aubert?= Date: Tue, 16 Jan 2018 17:57:22 +0100 Subject: [PATCH 2/2] Fix regression: default to all layers if layer filter is not provided --- lib/cartodb/controllers/named_maps.js | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/lib/cartodb/controllers/named_maps.js b/lib/cartodb/controllers/named_maps.js index 5744633a..92ba4ea6 100644 --- a/lib/cartodb/controllers/named_maps.js +++ b/lib/cartodb/controllers/named_maps.js @@ -85,6 +85,12 @@ NamedMapsController.prototype.getNamedMapProvider = function (label) { const { user } = res.locals; const { config, auth_token } = req.query; const { template_id } = req.params; + + // We force always the tile to be generated using PNG because + // is the only format we support by now + res.locals.format = 'png'; + res.locals.layer = res.locals.layer || 'all'; + const params = getRequestParams(res.locals); this.namedMapProviderCache.get(user, template_id, config, auth_token, params, (err, namedMapProvider) => { @@ -311,10 +317,6 @@ NamedMapsController.prototype.getImage = function (label) { height = +height; const format = req.params.format === 'jpg' ? 'jpeg' : 'png'; - // We force always the tile to be generated using PNG because - // is the only format we support by now - res.locals.format = 'png'; - res.locals.layer = res.locals.layer || 'all'; if (zoom !== undefined && center) { return this.previewBackend.getImage(namedMapProvider, format, width, height, zoom, center,