From 80f9765a35e7f8f79f30a4c1bae4997e7d7945b9 Mon Sep 17 00:00:00 2001 From: Hannah Wolfe Date: Wed, 2 Jan 2019 19:18:19 +0000 Subject: [PATCH] Removed deprecated settings refs #10318 - cheap and dirty way of removing settings we don't use - rewritten the settingsFilter function as that was unnecessarily complex - aslo fixed the require of default-settings in the importer --- core/server/api/v0.1/settings.js | 12 ++++++------ core/server/api/v2/settings.js | 2 +- .../api/v2/utils/serializers/output/settings.js | 15 ++++++++------- .../data/importer/importers/data/settings.js | 2 +- 4 files changed, 16 insertions(+), 15 deletions(-) diff --git a/core/server/api/v0.1/settings.js b/core/server/api/v0.1/settings.js index 247a60f647..ba0803a3fc 100644 --- a/core/server/api/v0.1/settings.js +++ b/core/server/api/v0.1/settings.js @@ -30,14 +30,14 @@ let settings, * @returns {*} */ settingsFilter = (settings, filter) => { - return _.fromPairs(_.toPairs(settings).filter((setting) => { - if (filter) { - return _.some(filter.split(','), (f) => { - return setting[1].type === f; - }); + let filteredTypes = filter ? filter.split(',') : false; + return _.filter(settings, (setting) => { + if (filteredTypes) { + return _.includes(filteredTypes, setting.type); } + return true; - })); + }); }; /** diff --git a/core/server/api/v2/settings.js b/core/server/api/v2/settings.js index f9780cf260..f4c1914f08 100644 --- a/core/server/api/v2/settings.js +++ b/core/server/api/v2/settings.js @@ -28,7 +28,7 @@ module.exports = { // CASE: omit core settings unless internal request if (!frame.options.context.internal) { settings = _.filter(settings, (setting) => { - return setting.type !== 'core' && setting.key !== 'permalinks'; + return setting.type !== 'core'; }); } diff --git a/core/server/api/v2/utils/serializers/output/settings.js b/core/server/api/v2/utils/serializers/output/settings.js index 230c9fe478..e932abd951 100644 --- a/core/server/api/v2/utils/serializers/output/settings.js +++ b/core/server/api/v2/utils/serializers/output/settings.js @@ -1,5 +1,6 @@ const _ = require('lodash'); const _private = {}; +const deprecatedSettings = ['force_i18n', 'permalinks']; /** * ### Settings Filter @@ -10,14 +11,14 @@ const _private = {}; * @returns {*} */ _private.settingsFilter = (settings, filter) => { - return _.fromPairs(_.toPairs(settings).filter((setting) => { - if (filter) { - return _.some(filter.split(','), (f) => { - return setting[1].type === f; - }); + let filteredTypes = filter ? filter.split(',') : false; + return _.filter(settings, (setting) => { + if (filteredTypes) { + return _.includes(filteredTypes, setting.type) && !_.includes(deprecatedSettings, setting.key); } - return true; - })); + + return !_.includes(deprecatedSettings, setting.key); + }); }; module.exports = { diff --git a/core/server/data/importer/importers/data/settings.js b/core/server/data/importer/importers/data/settings.js index 57e5ecc6eb..2924da9be4 100644 --- a/core/server/data/importer/importers/data/settings.js +++ b/core/server/data/importer/importers/data/settings.js @@ -3,7 +3,7 @@ const debug = require('ghost-ignition').debug('importer:settings'), _ = require('lodash'), BaseImporter = require('./base'), models = require('../../../../models'), - defaultSettings = require('../../../schema/default-settings.json'), + defaultSettings = require('../../../schema').defaultSettings, labsDefaults = JSON.parse(defaultSettings.blog.labs.defaultValue); class SettingsImporter extends BaseImporter {