Migrations: Convert all sibling RTE blocks (closes #22979) - #22980
Conversation
…in the 13 RTE source code.
|
Claude finished @AndyButland's task in 5m 27s —— View job PR ReviewTarget: Fixes a v13→v17 upgrade regression where greedy
Important
Suggestions
Request ChangesThe removal of the old |
There was a problem hiding this comment.
Pull request overview
Fixes an upgrade migration bug (v13 → v17) where consecutive sibling <umb-rte-block> elements could be collapsed into a single regex match, leaving some data-content-udi values unconverted and causing downstream rendering artefacts.
Changes:
- Introduces
RteBlockHelperto centralize the RTE block UDI→key conversion logic with a non-greedy, attribute-scoped regex. - Updates both
ConvertRichTextEditorPropertiesandLocalLinkRteProcessorto use the shared helper instead of duplicated regex code. - Adds unit tests covering sibling-block scenarios and other edge cases.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| tests/Umbraco.Tests.UnitTests/Umbraco.Infrastructure/Migrations/Upgrade/Common/RteBlockHelperTests.cs | Adds unit tests validating correct per-block matching and conversion behavior, including the reported sibling-block reproducer. |
| src/Umbraco.Infrastructure/Migrations/Upgrade/V_15_0_0/LocalLinks/LocalLinkRteProcessor.cs | Replaces local duplicated conversion regex with the shared helper. |
| src/Umbraco.Infrastructure/Migrations/Upgrade/V_15_0_0/ConvertRichTextEditorProperties.cs | Replaces migration’s duplicated conversion regex with the shared helper. |
| src/Umbraco.Infrastructure/Migrations/Upgrade/Common/RteBlockHelper.cs | Adds shared regex + conversion implementation intended for the v15 RTE block migration and related processing. |
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
…and comment - Move RteBlockHelper back to Umbraco.Cms.Infrastructure.Migrations.Upgrade.V_15_0_0.LocalLinks to avoid a binary breaking change within the obsolete window (scheduled removal in v18). Kept as its own file rather than reverting it into LocalLinkRteProcessor.cs. - Add a <remarks> note on ConvertBlockUdisToKeys explaining that blocks with malformed UDIs are dropped rather than preserved. - Replace the opaque "fix recursive hiccup" comment in LocalLinkRteProcessor with one that describes what the line actually does. - Move RteBlockHelperTests back to mirror the production namespace. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Zeegaan
left a comment
There was a problem hiding this comment.
Looks good as a preventive measure, but I'm also a little concerned with blocks that have already been migrated 🤔
Presumably you have to re-save all your blocks to get it working again 😅
|
Yes, this doesn't handle migrations that have already occurred - it's only resolving the situation for new migrations that would run into the same issue. I don't feel we can really justify a "just in case" migration across all blocks in a minor release to clean-up anyone who has already migrated and still has some blocks unconverted. |
* Fix migration of embedded block data when blocks are direct siblings in the 13 RTE source code. * Apply suggestions from code review to update comments. Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com> * Address review: keep RteBlockHelper in original namespace; tidy docs and comment - Move RteBlockHelper back to Umbraco.Cms.Infrastructure.Migrations.Upgrade.V_15_0_0.LocalLinks to avoid a binary breaking change within the obsolete window (scheduled removal in v18). Kept as its own file rather than reverting it into LocalLinkRteProcessor.cs. - Add a <remarks> note on ConvertBlockUdisToKeys explaining that blocks with malformed UDIs are dropped rather than preserved. - Replace the opaque "fix recursive hiccup" comment in LocalLinkRteProcessor with one that describes what the line actually does. - Move RteBlockHelperTests back to mirror the production namespace. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> --------- Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com> Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
|
Cherry-picked into |
Description
This PR fixes a v13 → v17 upgrade bug where multiple direct-sibling
<umb-rte-block>elements in RTE markup were collapsed into a single match by the migration regex, leaving all-but-last sibling UDIs un-converted (data-content-key="umb://element/..."rather than the hyphenated GUID).The cause was a greedy
.*on both sides of the attribute capture inConvertRichTextEditorProperties.BlockRegex()(and its verbatim copy inLocalLinkRteProcessor). Replaced with a non-greedy, attribute-scoped pattern that matches each block independently.I've also consolidated the regex + replacement lambda which previously duplicated across two migrations (and would also have been a third time in the tests I've added. So now both production sites and the new tests now share one implementation.
The "duplicate blocks at the top of the editor" symptom reported in the issue is a downstream TipTap render-time artefact of
contentDataentries that don't have a matching key in the markup. Once the keys in the markup are fixed, TipTap finds every match and stops inserting placeholders — no separate fix needed.Fixes #22979
Testing
Automated
I've added new
RteBlockHelperTeststhat verify this an existing functionality. The tests related to this fix fail against the original greedy regex and pass against the new one.Manual
Spin up a site on 13, create an element type for a block and a document type for a page with a rich text editor. Configure the rich text editor to add the "Add Block" toolbar button and allow the element type as a block.
Create a content item and add two, sibling blocks to the RTE, and save.
Use that database to upgrade to 17.
You should see something like the following when you view the source of the RTE (which is what I got from my local test):
13:
Pre-fix upgrade to 17:
Post-fix upgrade to 17: