Migrations: Align type attribute casing in locallink migration for integer-based legacy links (closes #22597)#22599
Conversation
…istent type attribute casing.
|
Claude finished @AndyButland's task in 2m 28s —— View job PR ReviewTarget: Fixes a casing mismatch in the v15 local-link migration: integer-based legacy links were being tagged No breaking changes — both processor classes are already No Critical, Important, or Suggestion findings. The fix is minimal and precisely targeted. Test coverage across the two integer-based code paths and the trailing-content variants is adequate. ApprovedThis looks good to be merged as-is. The PR description's note about already-migrated sites needing a republish to pick up the corrected markup is accurate and worth keeping visible for whoever merges. |
There was a problem hiding this comment.
Pull request overview
Fixes a migration bug in the v15 ConvertLocalLinks upgrade step where integer-based legacy {localLink:1234} conversions produced type="Document" / type="Media" instead of the lowercase values expected by Tiptap and the rest of the link pipeline.
Changes:
- Update the integer-ID conversion branch to emit lowercase entity types using
Constants.UdiEntityType.Document/.Media. - Apply the same casing fix in
LocalLinkProcessorForFaultyLinks’s (currently unused) integer conversion helper for consistency. - Update unit tests to assert the corrected lowercase
typeattribute values.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
src/Umbraco.Infrastructure/Migrations/Upgrade/V_15_0_0/LocalLinks/LocalLinkProcessor.cs |
Fixes int-based local link type casing by using Constants.UdiEntityType.* to match the UDI-based branch output. |
src/Umbraco.Infrastructure/Migrations/Upgrade/V_15_0_0/LocalLinks/LocalLinkProcessorForFaultyLinks.cs |
Aligns the int-based helper’s entity type casing with Constants.UdiEntityType.* to avoid reintroducing the bug if used later. |
tests/Umbraco.Tests.UnitTests/Umbraco.Infrastructure/Migrations/LocalLinkProcessorTests.cs |
Updates assertions/comments to validate lowercase type="document" / type="media" for integer-based conversions. |
|
@AndyButland What do we do about sites having already run this migration? Presumably they will have the wrong uppercase |
It's a good point. Would be better to avoid another migration if we could. This step is rather a heavy one, particularly on larger sites. Better probably is if we can gracefully handle Pascal named types - e.g. "Document" - and I think we can. I've pushed an update to do that. For testing I've verified with unit tests, and manually via:
|
Description
#22597 reports a casing discrepancy in the
ConvertLocalLinksmigration between the legacy GUID UDI and integer formats. The former emit "document"/"media" and the latter "Document"/"Media". The former is expected (comparing toConstants.UdiEntityType.*).The fix switches the integer branch to use
Constants.UdiEntityType.Document("document") and.Media("media") so the two branches produce matching lowercase output.Testing
Automated
LocalLinkProcessorTestsare updated to reflect the change (they were previously incorrectly passing as they were asserting the incorrect case).Manual
To verify against a real database, I have used the following method. Bear in mind it will replay all migrations since 15. Doesn't do any harm, but don't run on anything important.
current = 1orpublished = 1versions):IIdKeyMap.GetKeyForIdhas to resolve it, so it must correspond to an actual node):textValueof the property data row before overwriting it, so you can restore it afterwards:ConvertLocalLinksruns again on the seeded row. The state ID is taken fromUmbracoPlan.cs— it's the state produced by the migration beforeConvertLocalLinks:Start the site. Watch the log for
Migration starting for all properties of type: Umbraco.RichText.Inspect the stored value after the migration runs. Expect
type="document"(lowercase). Before the fix it wastype="Document". The href will contain the GUID for the target node (umbracoNode.uniqueId):