Skip to content

Conversation

@sayalijoshi27
Copy link
Contributor

@sayalijoshi27 sayalijoshi27 commented Aug 12, 2025

Issue with Wordpress Connector. Case #00044506 for Horizontal

@sayalijoshi27 sayalijoshi27 requested a review from a team as a code owner August 12, 2025 10:50
@umeshmore45 umeshmore45 requested a review from Copilot August 12, 2025 10:51
@sayalijoshi27 sayalijoshi27 changed the title [CMG-698] - Issue with Wordpress Connector. Case #00044506 for Horizo… [CMG-698] - Issue with Wordpress Connector. Case #00044506 for Horizontal Aug 12, 2025
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR addresses issues with the WordPress connector, specifically fixing the featured image mapping functionality and improving UI styling for log messages. The main changes include refactoring the featured image mapping to properly use the assets schema path, adding a new Pages content type schema, and updating log message styling in the UI.

  • Fixes featured image mapping by using the passed assets schema path instead of global variables
  • Adds complete Pages content type schema definition for WordPress migration
  • Updates UI styling for log messages with a new generic class

Reviewed Changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
upload-api/migration-wordpress/libs/content_types.js Adds new Pages content type schema with fields for title, URL, slug, body, excerpt, featured image, date, author, and related pages
api/src/services/wordpress.service.ts Refactors featured image mapping function to use passed assets schema path, simplifies post processing logic, and adds assets schema path parameter to page processing functions
ui/src/components/LogScreen/index.tsx Updates notification settings to hide progress bar and adds generic-log-message CSS class to log messages
ui/src/components/LogScreen/MigrationLogViewer.tsx Applies same notification and styling changes as in index.tsx
ui/src/components/LogScreen/index.scss Adds CSS styling for generic-log-message class with different padding
.talismanrc Updates file checksums and removes duplicate configuration entries

// Step 1: Resolve all references for the CURRENT post
const { postCategories, postTags, postTerms } = extractPostCategories(data["category"], referencesFilePath);
const postAuthor = extractPostAuthor(data["dc:creator"], authorsFilePath);
const jsonValue = htmlToJson(new JSDOM(data["content:encoded"].replace("//g", "").replace(/<!--?\s+\/?wp:.*?-->/g, "")).window.document.querySelector("body"));
Copy link

Copilot AI Aug 12, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The regex pattern "//g" in the replace function is incorrect. It should be /<!--.*?-->/g to properly remove HTML comments.

Suggested change
const jsonValue = htmlToJson(new JSDOM(data["content:encoded"].replace("//g", "").replace(/&lt;!--?\s+\/?wp:.*?--&gt;/g, "")).window.document.querySelector("body"));
const jsonValue = htmlToJson(new JSDOM(data["content:encoded"].replace(/<!--.*?-->/gs, "").replace(/&lt;!--?\s+\/?wp:.*?--&gt;/g, "")).window.document.querySelector("body"));

Copilot uses AI. Check for mistakes.
url: data["link"]?.split(blog_base_url?.split("/").filter(Boolean).pop())[1],
date: postDate,
full_description: jsonValue,
excerpt: (data["excerpt:encoded"] || "").replace("//g", "").replace(/&lt;!--?\s+\/?wp:.*?--&gt;/g, ""),
Copy link

Copilot AI Aug 12, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The regex pattern "//g" in the replace function is incorrect. It should be /<!--.*?-->/g to properly remove HTML comments.

Suggested change
excerpt: (data["excerpt:encoded"] || "").replace("//g", "").replace(/&lt;!--?\s+\/?wp:.*?--&gt;/g, ""),
excerpt: (data["excerpt:encoded"] || "").replace(/<!--.*?-->/gs, "").replace(/&lt;!--?\s+\/?wp:.*?--&gt;/g, ""),

Copilot uses AI. Check for mistakes.
// 1. Resolve references for the current item
const authorRef = extractPageAuthor(item['dc:creator'], authorsFilePath);
const parentRef = extractPageParent(item['wp:post_parent']);
const body = htmlToJson(new JSDOM(item["content:encoded"].replace("//g", "").replace(/&lt;!--?\s+\/?wp:.*?--&gt;/g, "")).window.document.querySelector('body'));
Copy link

Copilot AI Aug 12, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The regex pattern "//g" in the replace function is incorrect. It should be /<!--.*?-->/g to properly remove HTML comments.

Suggested change
const body = htmlToJson(new JSDOM(item["content:encoded"].replace("//g", "").replace(/&lt;!--?\s+\/?wp:.*?--&gt;/g, "")).window.document.querySelector('body'));
const body = htmlToJson(new JSDOM(item["content:encoded"].replace(/<!--.*?-->/g, "").replace(/&lt;!--?\s+\/?wp:.*?--&gt;/g, "")).window.document.querySelector('body'));

Copilot uses AI. Check for mistakes.
const postmetaArray = Array.isArray(post["wp:postmeta"]) ? post["wp:postmeta"] : [post["wp:postmeta"]];

const assetsDetails = postmetaArray
.filter((meta) => meta["wp:meta_key"] === "_thumbnail_id")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

meta?.["wp:meta_key"]

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Array.isArray(post?.["wp:postmeta"])
? post["wp:postmeta"]
: (post?.["wp:postmeta"] ? [post["wp:postmeta"]] : [])

const postmetaArray = Array.isArray(post["wp:postmeta"]) ? post["wp:postmeta"] : [post["wp:postmeta"]];

const assetsDetails = postmetaArray
.filter((meta) => meta["wp:meta_key"] === "_thumbnail_id")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

meta?.["wp:meta_key"]

.filter(Boolean);

if (assetsDetails?.length > 0) {
if (assetsDetails.length > 0 && postdata[postid]) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

assetsDetails?.length > 0 && postdata?.[postid]

);
})
.filter(Boolean); // Filter out undefined matches
.filter(Boolean);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

const assetsDetails = postmetaArray
?.filter?.((meta) => meta?.["wp:meta_key"] === "_thumbnail_id")
.map((meta) => {
const attachmentid = assets_${meta?.["wp:meta_value"]};

    return Object.values(assetsId)?.find(
      (asset: any) => asset?.uid === attachmentid
    );
  })
  ?.filter(Boolean); 

const writePromises = [];
// This filter is good, it correctly selects only post-like items.
const filteredChunk = chunkData?.filter((item: any) =>
item["wp:post_type"] !== "page" &&
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

?.

};
formattedPosts[customId].publish_details = [];
}
const customId = idCorrector(`posts_${data["wp:post_id"]}`);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

data?.["wp:post_id"]

const customId = idCorrector(`posts_${data["wp:post_id"]}`);

// Step 1: Resolve all references for the CURRENT post
const { postCategories, postTags, postTerms } = extractPostCategories(data["category"], referencesFilePath);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

data?.["category"]

or for global use if(data)

console.info("last data");

// Step 5: Add the final, complete post to the combined results
if (formattedPostWithImage && formattedPostWithImage[customId]) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

formattedPostWithImage?.[customId]

@umeshmore45 umeshmore45 merged commit 51d4026 into dev Aug 12, 2025
7 checks passed
@umeshmore45 umeshmore45 deleted the bugfix/cmg-698 branch August 12, 2025 11:42
@sayalijoshi27 sayalijoshi27 restored the bugfix/cmg-698 branch August 12, 2025 12:57
@aravindbuilt aravindbuilt deleted the bugfix/cmg-698 branch September 23, 2025 11:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants