Skip to content

Commit 01098dc

Browse files
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 2bdd5a5) Co-authored-by: Tyler Barnes <[email protected]>
1 parent d616e65 commit 01098dc

File tree

1 file changed

+23
-12
lines changed

1 file changed

+23
-12
lines changed

packages/gatsby-source-wordpress/src/steps/source-nodes/fetch-nodes/fetch-nodes-paginated.js

Lines changed: 23 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -95,24 +95,35 @@ const paginatedWpNodeFetch = async ({
9595
nodes.forEach(node => {
9696
const existingId = idSet.has(node.id)
9797

98-
if (existingId) {
98+
if (
99+
existingId &&
100+
// when the since variable is present
101+
// we're fetching lists of node updates from WPGQL
102+
// in that case we don't need to worry about logging duplicates
103+
!(`since` in variables)
104+
) {
99105
const existingNode = allContentNodes.find(
100106
innerNode => innerNode.id === node.id
101107
)
102108

103-
if (!hasLoggedDuplicateMessage) {
104-
hasLoggedDuplicateMessage = true
105-
helpers.reporter.warn(
106-
formatLogMessage(
107-
`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.`
109+
if (existingNode) {
110+
if (!hasLoggedDuplicateMessage) {
111+
hasLoggedDuplicateMessage = true
112+
helpers.reporter.warn(
113+
formatLogMessage(
114+
`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.`
115+
)
108116
)
109-
)
117+
}
118+
119+
if (node?.databaseId && node?.uri && existingNode?.uri) {
120+
helpers.reporter.info(
121+
formatLogMessage(
122+
`#${node.databaseId} (${node.uri}) is a duplicate of ${existingNode.databaseId} (${existingNode.uri})`
123+
)
124+
)
125+
}
110126
}
111-
helpers.reporter.info(
112-
formatLogMessage(
113-
`#${node.databaseId} (${node?.uri}) is a duplicate of ${existingNode.databaseId} (${existingNode?.uri})`
114-
)
115-
)
116127
} else {
117128
idSet.add(node.id)
118129
}

0 commit comments

Comments
 (0)