From ea6d656457eb9088c5a121fc8b3a4920a4e1b903 Mon Sep 17 00:00:00 2001 From: Naz Date: Fri, 12 Feb 2021 22:47:06 +1300 Subject: [PATCH] =?UTF-8?q?=F0=9F=8F=97=20=20Removed=20labs=20from=20setti?= =?UTF-8?q?ng?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit refs https://github.com/TryGhost/Team/issues/332 - The last value that has been used in the code was "members" - By default members will be always "on" starting Ghost 4.0, so there's no need for this flag anymore - Therefore there's no real need to keep "labs" around --- .../data/importer/importers/data/settings.js | 9 --------- .../4.0/19-remove-labs-members-setting.js | 10 ++++++++++ core/server/data/schema/default-settings.json | 6 ------ test/api-acceptance/admin/settings_spec.js | 15 ++++----------- test/unit/data/schema/integrity_spec.js | 2 +- 5 files changed, 15 insertions(+), 27 deletions(-) create mode 100644 core/server/data/migrations/versions/4.0/19-remove-labs-members-setting.js diff --git a/core/server/data/importer/importers/data/settings.js b/core/server/data/importer/importers/data/settings.js index 3a06fc7718..af125908f6 100644 --- a/core/server/data/importer/importers/data/settings.js +++ b/core/server/data/importer/importers/data/settings.js @@ -4,11 +4,9 @@ const ObjectId = require('bson-objectid').default; const _ = require('lodash'); const BaseImporter = require('./base'); const models = require('../../../../models'); -const defaultSettings = require('../../../schema').defaultSettings; const keyGroupMapper = require('../../../../api/shared/serializers/input/utils/settings-key-group-mapper'); const keyTypeMapper = require('../../../../api/shared/serializers/input/utils/settings-key-type-mapper'); -const labsDefaults = JSON.parse(defaultSettings.labs.labs.defaultValue); const ignoredSettings = ['slack_url', 'members_from_address', 'members_support_address']; // NOTE: drop support in Ghost 5.0 @@ -73,7 +71,6 @@ class SettingsImporter extends BaseImporter { /** * - 'core' and 'theme' are blacklisted - * - handle labs setting */ beforeImport() { debug('beforeImport'); @@ -183,12 +180,6 @@ class SettingsImporter extends BaseImporter { } _.each(this.dataToImport, (obj) => { - if (obj.key === 'labs' && obj.value) { - // Overwrite the labs setting with our current defaults - // Ensures things that are enabled in new versions, are turned on - obj.value = JSON.stringify(_.assign({}, JSON.parse(obj.value), labsDefaults)); - } - // CASE: we do not import "from address" for members settings as that needs to go via validation with magic link if ((obj.key === 'members_from_address') || (obj.key === 'members_support_address')) { obj.value = null; diff --git a/core/server/data/migrations/versions/4.0/19-remove-labs-members-setting.js b/core/server/data/migrations/versions/4.0/19-remove-labs-members-setting.js new file mode 100644 index 0000000000..9f3b834db2 --- /dev/null +++ b/core/server/data/migrations/versions/4.0/19-remove-labs-members-setting.js @@ -0,0 +1,10 @@ +const logging = require('../../../../../shared/logging'); +const {createIrreversibleMigration} = require('../../utils'); + +module.exports = createIrreversibleMigration(async (knex) => { + logging.info('Deleting labs from settings table'); + + await knex('settings') + .where('key', '=', 'labs') + .del(); +}); diff --git a/core/server/data/schema/default-settings.json b/core/server/data/schema/default-settings.json index 9cd2ab1db0..15f65730b9 100644 --- a/core/server/data/schema/default-settings.json +++ b/core/server/data/schema/default-settings.json @@ -394,12 +394,6 @@ "type": "string" } }, - "labs": { - "labs": { - "defaultValue": "{}", - "type": "object" - } - }, "slack": { "slack_url": { "defaultValue": "", diff --git a/test/api-acceptance/admin/settings_spec.js b/test/api-acceptance/admin/settings_spec.js index 3edf4c04c6..8ba06f0304 100644 --- a/test/api-acceptance/admin/settings_spec.js +++ b/test/api-acceptance/admin/settings_spec.js @@ -138,10 +138,6 @@ describe('Settings API', function () { key: 'twitter_description', value: 'twitter description' }, - { - key: 'labs', - value: '{"subscribers":false,"members":true}' - }, { key: 'lang', value: 'ua' @@ -211,14 +207,11 @@ describe('Settings API', function () { putBody.settings[12].key.should.eql('twitter_description'); should.equal(putBody.settings[12].value, 'twitter description'); - putBody.settings[13].key.should.eql('labs'); - should.equal(putBody.settings[13].value, '{"subscribers":false,"members":true}'); + putBody.settings[13].key.should.eql('lang'); + should.equal(putBody.settings[13].value, 'ua'); - putBody.settings[14].key.should.eql('lang'); - should.equal(putBody.settings[14].value, 'ua'); - - putBody.settings[15].key.should.eql('timezone'); - should.equal(putBody.settings[15].value, 'Pacific/Auckland'); + putBody.settings[14].key.should.eql('timezone'); + should.equal(putBody.settings[14].value, 'Pacific/Auckland'); putBody.settings[16].key.should.eql('slack'); should.equal(putBody.settings[16].value, JSON.stringify([{ diff --git a/test/unit/data/schema/integrity_spec.js b/test/unit/data/schema/integrity_spec.js index 3c6b4b824e..77e2a311fe 100644 --- a/test/unit/data/schema/integrity_spec.js +++ b/test/unit/data/schema/integrity_spec.js @@ -34,7 +34,7 @@ describe('DB version integrity', function () { // Only these variables should need updating const currentSchemaHash = '5861ed57418a0195ea01e431b8b55335'; const currentFixturesHash = '370d0da0ab7c45050b2ff30bce8896ba'; - const currentSettingsHash = '24453dc02be9df7284acf1748862a545'; + const currentSettingsHash = '6db8d92f1b76b43946bf75fbac78599d'; const currentRoutesHash = '3d180d52c663d173a6be791ef411ed01'; // If this test is failing, then it is likely a change has been made that requires a DB version bump,