wp-parsely
wp-parsely copied to clipboard
PCH Smart Linking: Fix removal of existing Smart Links on subsequent runs
Description
It was reported that when running the Smart Linking a second time in the same block would remove the existing Smart Links from that block and insert the new ones. This seems to be happening since at least WP 6.5.3.
This PR changes the how we were obtaining the block content - using originalContent
- and now it uses the more appropriate getBlockContent
function to get the most up-to-date content for that given block.
Motivation and context
Improve the reliability of the Parse.ly plugin and the Smart Linking feature in the latest WordPress release.
How has this been tested?
Tested locally by generating Smart Links on the same block multiple times, none of these tests resulted in the removal of any existing smart links.
Summary by CodeRabbit
-
Enhancements
- Improved the smart linking feature within the editor sidebar, enhancing link generation and application based on content blocks and attributes.
Walkthrough
The update in the code primarily enhances the smart linking feature within the editor sidebar. It improves how block content is accessed and smart links are applied, optimizing the overall functionality and user experience in managing links based on content and attributes.
Changes
File Path | Summary of Changes |
---|---|
.../editor-sidebar/smart-linking/component.tsx |
Adjusted access to block content and optimized smart linking in the editor sidebar. |
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?
Tips
Chat
There are 3 ways to chat with CodeRabbit:
- Review comments: Directly reply to a review comment made by CodeRabbit. Example:
-
I pushed a fix in commit <commit_id>.
-
Generate unit testing code for this file.
-
Open a follow-up GitHub issue for this discussion.
-
- Files and specific lines of code (under the "Files changed" tab): Tag
@coderabbitai
in a new review comment at the desired location with your query. Examples:-
@coderabbitai generate unit testing code for this file.
-
@coderabbitai modularize this function.
-
- PR comments: Tag
@coderabbitai
in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:-
@coderabbitai generate interesting stats about this repository and render them as a table.
-
@coderabbitai show all the console.log statements in this repository.
-
@coderabbitai read src/utils.ts and generate unit testing code.
-
@coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
-
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.
CodeRabbit Commands (invoked as PR comments)
-
@coderabbitai pause
to pause the reviews on a PR. -
@coderabbitai resume
to resume the paused reviews. -
@coderabbitai review
to trigger a review. This is useful when automatic reviews are disabled for the repository. -
@coderabbitai resolve
resolve all the CodeRabbit review comments. -
@coderabbitai help
to get help.
Additionally, you can add @coderabbitai ignore
anywhere in the PR description to prevent this PR from being reviewed.
CodeRabbit Configration File (.coderabbit.yaml
)
- You can programmatically configure CodeRabbit by adding a
.coderabbit.yaml
file to the root of your repository. - Please see the configuration documentation for more information.
- If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation:
# yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json
Documentation and Community
- Visit our Documentation for detailed information on how to use CodeRabbit.
- Join our Discord Community to get help, request features, and share feedback.
- Follow us on X/Twitter for updates and announcements.
This is related and closes #2422
Some questions/thoughts:
- Would it be easy to implement this solution for a 3.14.4 patch release (base 3.14.3), or does it make things complicated because of other changes?
- It is mentioned here that this solution keeps previous smart links. I assume this means that it also keeps user-defined links intact.
- Whether this gets to be a part of a 3.14.4 patch release or 3.15, we should make sure it works in previous WordPress versions. Testing this with WordPress Playground should be easy, and this should work from at least WP 6.3 and newer. But let's decide first if it will be part of a patch or minor release to avoid more duplicate work.
Thank you for your questions!
Would it be easy to implement this solution for a 3.14.4 patch release (base 3.14.3), or does it make things complicated because of other changes?
That's a good question. If we are going to push this to 3.14.3 base, it might have conflict with a few recent PRs, namely the #2401 (provider refactoring) and API retries (#2386). Although it should be relatively easy to fix manually.
It is mentioned here that this solution keeps previous smart links. I assume this means that it also keeps user-defined links intact.
Yes, that is correct! The user-defined links were never a problem, since they were included in the block's originalContent
prop already. So these will (still) be preserved.
Whether this gets to be a part of a 3.14.4 patch release or 3.15, we should make sure it works in previous WordPress versions. Testing this with WordPress Playground should be easy, and this should work from at least WP 6.3 and newer. But let's decide first if it will be part of a patch or minor release to avoid more duplicate work.
Yeah, agreed. I think it should, since this function - getBlockContent
- is three years old. But I will spin up a test env and give it a try. I will update here with the results.
Yeah, agreed. I think it should, since this function - getBlockContent - is three years old. But I will spin up a test env and give it a try. I will update here with the results.
Update: it works as expected in 6.3, validated with a wp-now environment 🙂
If we are going to push this to 3.14.3 base, it might have conflict with a few recent PRs, namely the https://github.com/Parsely/wp-parsely/pull/2401 (provider refactoring) and API retries (https://github.com/Parsely/wp-parsely/pull/2386). Although it should be relatively easy to fix manually.
I think the way I'd approach this is to just branch from 3.14.3 and add the updated function/code there, with any needed adaptations. Attempting to merge the current work could bring a lot of code in, and more points of failure which we don't want in a patch release. I hope I'm making sense. What do you think?
I think the way I'd approach this is to just branch from 3.14.3 and add the updated function/code there, with any needed adaptations. Attempting to merge the current work could bring a lot of code in, and more points of failure which we don't want in a patch release. I hope I'm making sense. What do you think?
Sounds good to me, yes!
Hello, I see you re-requested a review. I think it might make more sense to make create and merge the 3.14.4 PR first, just in case this PR becomes redundant. No issue approving though 🙂
Looking into this because I see it having conflicts but I wouldn't expect it to.
@vaurdan, after merging develop
into this, there seems to be only one whitespace change. I propose closing this PR and integrating the whitespace change in any Smart Linking work you're doing, or just ignore the change.
Sounds good to me! Closing this one.