From 96f55c528ed03dfb2565847d93acee7c44115849 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bar=C4=B1=C5=9F=20Soner=20U=C5=9Fakl=C4=B1?= Date: Fri, 9 Mar 2018 11:11:59 -0500 Subject: [PATCH] don't crash if config is undefined --- src/widgets/index.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/widgets/index.js b/src/widgets/index.js index 7a77c34148..41fcb4eae0 100644 --- a/src/widgets/index.js +++ b/src/widgets/index.js @@ -9,6 +9,7 @@ var plugins = require('../plugins'); var translator = require('../translator'); var db = require('../database'); var apiController = require('../controllers/api'); +var meta = require('../meta'); var widgets = module.exports; @@ -67,11 +68,11 @@ function renderWidget(widget, uid, options, callback) { if (options.res.locals.isAPI) { apiController.loadConfig(options.req, next); } else { - next(null, options.res.locals.config); + next(null, options.res.locals.config || {}); } }, function (config, next) { - userLang = config.userLang; + userLang = config.userLang || meta.config.defaultLang || 'en-GB'; var templateData = _.assign({ }, options.templateData, { config: config }); plugins.fireHook('filter:widget.render:' + widget.widget, { uid: uid,