From 5519b1f0ac2b30f8249ee261ed80d8da1190704b Mon Sep 17 00:00:00 2001 From: Tyler Barnes Date: Thu, 8 Apr 2021 08:41:29 -0700 Subject: [PATCH] fix(gatsby-source-wordpress): only log out duplicate node if we have all the data we want to log (#30751) (cherry picked from commit 2bdd5a5865b696e0d31dd8ff3c0dde6fdd7cb181) --- .../fetch-nodes/fetch-nodes-paginated.js | 35 ++++++++++++------- 1 file changed, 23 insertions(+), 12 deletions(-) diff --git a/packages/gatsby-source-wordpress/src/steps/source-nodes/fetch-nodes/fetch-nodes-paginated.js b/packages/gatsby-source-wordpress/src/steps/source-nodes/fetch-nodes/fetch-nodes-paginated.js index 843e4cee19949..a604f2f31a9dd 100644 --- a/packages/gatsby-source-wordpress/src/steps/source-nodes/fetch-nodes/fetch-nodes-paginated.js +++ b/packages/gatsby-source-wordpress/src/steps/source-nodes/fetch-nodes/fetch-nodes-paginated.js @@ -95,24 +95,35 @@ const paginatedWpNodeFetch = async ({ nodes.forEach(node => { const existingId = idSet.has(node.id) - if (existingId) { + if ( + existingId && + // when the since variable is present + // we're fetching lists of node updates from WPGQL + // in that case we don't need to worry about logging duplicates + !(`since` in variables) + ) { const existingNode = allContentNodes.find( innerNode => innerNode.id === node.id ) - if (!hasLoggedDuplicateMessage) { - hasLoggedDuplicateMessage = true - helpers.reporter.warn( - formatLogMessage( - `Found a duplicate ID in WordPress - this means you will have fewer nodes in Gatsby than in WordPress. This will need to be resolved in WP by identifying and fixing the underlying bug with your WP plugins or custom code.` + if (existingNode) { + if (!hasLoggedDuplicateMessage) { + hasLoggedDuplicateMessage = true + helpers.reporter.warn( + formatLogMessage( + `Found a duplicate ID in WordPress - this means you will have fewer nodes in Gatsby than in WordPress. This will need to be resolved in WP by identifying and fixing the underlying bug with your WP plugins or custom code.` + ) ) - ) + } + + if (node?.databaseId && node?.uri && existingNode?.uri) { + helpers.reporter.info( + formatLogMessage( + `#${node.databaseId} (${node.uri}) is a duplicate of ${existingNode.databaseId} (${existingNode.uri})` + ) + ) + } } - helpers.reporter.info( - formatLogMessage( - `#${node.databaseId} (${node?.uri}) is a duplicate of ${existingNode.databaseId} (${existingNode?.uri})` - ) - ) } else { idSet.add(node.id) }