From 01098dccb33c89f7bb63ca45d3e6359060fcbf4f Mon Sep 17 00:00:00 2001 From: Lennart Date: Fri, 9 Apr 2021 09:30:30 +0200 Subject: [PATCH] fix(gatsby-source-wordpress): only log out duplicate nodes if we have all the data we want to log (#30751) (#30759) (cherry picked from commit 2bdd5a5865b696e0d31dd8ff3c0dde6fdd7cb181) Co-authored-by: Tyler Barnes --- .../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) }