From 46508b729939d284e1ff05fb0470dbd48ad6cca2 Mon Sep 17 00:00:00 2001 From: Naz Date: Wed, 8 Mar 2023 15:24:21 +0800 Subject: [PATCH] Fixed external media inliner logs refs https://github.com/TryGhost/Toolbox/issues/524 - The "tableName" property is not present on the bookshelf model instance - it was a mistake assumption using it for logs. In case the logs are too ambiguous we could figure pass around model names separately into the "inlineSimpleFields" method --- ghost/external-media-inliner/lib/ExternalMediaInliner.js | 4 ++-- .../test/ExternalMediaInliner.test.js | 6 +----- 2 files changed, 3 insertions(+), 7 deletions(-) diff --git a/ghost/external-media-inliner/lib/ExternalMediaInliner.js b/ghost/external-media-inliner/lib/ExternalMediaInliner.js index 3899a57ac5..5d6967f53f 100644 --- a/ghost/external-media-inliner/lib/ExternalMediaInliner.js +++ b/ghost/external-media-inliner/lib/ExternalMediaInliner.js @@ -187,7 +187,7 @@ class ExternalMediaInliner { * @param {string[]} domains - domains to inline media from */ async #inlineSimpleFields(resources, model, fields, domains) { - logging.info(`Starting inlining external media for ${resources?.length} ${model.tableName}`); + logging.info(`Starting inlining external media for ${resources?.length} resources and with ${fields.join(', ')} fields`); for (const resource of resources) { try { @@ -202,7 +202,7 @@ class ExternalMediaInliner { }); } } catch (err) { - logging.error(`Error inlining media for ${model.tableName}: ${resource.id}`); + logging.error(`Error inlining media for: ${resource.id}`); logging.error(new errors.DataImportError({ err })); diff --git a/ghost/external-media-inliner/test/ExternalMediaInliner.test.js b/ghost/external-media-inliner/test/ExternalMediaInliner.test.js index df04a2d8c1..0be4a41119 100644 --- a/ghost/external-media-inliner/test/ExternalMediaInliner.test.js +++ b/ghost/external-media-inliner/test/ExternalMediaInliner.test.js @@ -23,28 +23,24 @@ describe('ExternalMediaInliner', function () { }; postModelStub = { - tableName: 'posts', findPage: sinon.stub().resolves({ data: [] }), edit: sinon.stub().resolves() }; postMetaModelStub = { - tableName: 'posts_meta', findPage: sinon.stub().resolves({ data: [] }), edit: sinon.stub().resolves() }; tagModelStub = { - tableName: 'tags', findPage: sinon.stub().resolves({ data: [] }), edit: sinon.stub().resolves() }; userModelStub = { - tableName: 'users', findPage: sinon.stub().resolves({ data: [] }), @@ -335,7 +331,7 @@ describe('ExternalMediaInliner', function () { assert.ok(requestMock.isDone()); assert.ok(tagModelStub.edit.calledOnce); - assert.equal(logging.error.args[0][0], 'Error inlining media for tags: errored-tag-id'); + assert.equal(logging.error.args[0][0], 'Error inlining media for: errored-tag-id'); }); it('inlines image in the post\'s feature_image field', async function () {