Skip to content

Commit

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

(cherry picked from commit 2bdd5a5)
  • Loading branch information
TylerBarnes authored and LekoArts committed Apr 8, 2021
1 parent d616e65 commit 5519b1f
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 5519b1f

Please sign in to comment.