Skip to content

Commit

Permalink
fix(gatsby-source-wordpress): only log out duplicate nodes if we have…
Browse files Browse the repository at this point in the history
… all the data we want to log (#30751) (#30759)

(cherry picked from commit 2bdd5a5)

Co-authored-by: Tyler Barnes <tyler@gatsbyjs.com>
  • Loading branch information
LekoArts and TylerBarnes committed Apr 9, 2021
1 parent d616e65 commit 01098dc
Showing 1 changed file with 23 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down

0 comments on commit 01098dc

Please sign in to comment.