diff --git a/core/server/models/base/index.js b/core/server/models/base/index.js index 018f26a49d..60c1b2612c 100644 --- a/core/server/models/base/index.js +++ b/core/server/models/base/index.js @@ -311,13 +311,13 @@ ghostBookshelf.Model = ghostBookshelf.Model.extend({ onCreating: function onCreating(model, attr, options) { if (schema.tables[this.tableName].hasOwnProperty('created_by')) { if (!options.importing || (options.importing && !this.get('created_by'))) { - this.set('created_by', this.contextUser(options)); + this.set('created_by', String(this.contextUser(options))); } } if (schema.tables[this.tableName].hasOwnProperty('updated_by')) { if (!options.importing) { - this.set('updated_by', this.contextUser(options)); + this.set('updated_by', String(this.contextUser(options))); } } @@ -377,7 +377,7 @@ ghostBookshelf.Model = ghostBookshelf.Model.extend({ if (schema.tables[this.tableName].hasOwnProperty('updated_by')) { if (!options.importing && !options.migrating) { - this.set('updated_by', this.contextUser(options)); + this.set('updated_by', String(this.contextUser(options))); } } @@ -390,7 +390,7 @@ ghostBookshelf.Model = ghostBookshelf.Model.extend({ if (schema.tables[this.tableName].hasOwnProperty('created_by')) { if (model.hasChanged('created_by')) { - model.set('created_by', this.previous('created_by')); + model.set('created_by', String(this.previous('created_by'))); } } } diff --git a/core/server/models/post.js b/core/server/models/post.js index bff7a4d803..aba1ef137b 100644 --- a/core/server/models/post.js +++ b/core/server/models/post.js @@ -388,12 +388,12 @@ Post = ghostBookshelf.Model.extend({ if (newStatus === 'published' && this.hasChanged('status')) { // unless published_by is set and we're importing, set published_by to contextUser if (!(this.get('published_by') && options.importing)) { - this.set('published_by', this.contextUser(options)); + this.set('published_by', String(this.contextUser(options))); } } else { // In any other case (except import), `published_by` should not be changed if (this.hasChanged('published_by') && !options.importing) { - this.set('published_by', this.previous('published_by') || null); + this.set('published_by', this.previous('published_by') ? String(this.previous('published_by')) : null); } }