Skip to content

Conversation

@AndyButland
Copy link
Contributor

@AndyButland AndyButland commented Nov 19, 2025

Prerequisites

  • I have added steps to test this contribution in the description below

Addresses: #20885

Description

This PR contains two updates to address issues found in testing the database provided illustrating the problem encountered in the linked issue.

The most important is the report of block data from blocks in the RTE being removed after the upgrade. I tracked this down to the ConvertLocalLinks migration, which requires serializing the rich text content. As in the 13 the layout values key is "Umbraco.TinyMCE" rather than "Umbraco.RichText", these are omitted, and an empty block value is returned. I've resolved that by supporting this key as well, such that the existing values will be read.

The second fix is that I noticed that after the migration, when accessing certain content, an error of being unable to find a data type by Id is thrown. This was referring to one of the data types added in a migration - the "Label (pixels)" one. Although we clear caches after the migration completes, there's an internal cache of datatypes in PublishedContentTypeFactory that isn't cleared. So I've added a means of doing that and executed it along with the other post-migration cache invalidations.

Point to note

In testing this I've also seen that the markup will get encoded via this ConvertLocalLinks migration, so starting from:

{"markup":"<p>Two weeks ago, I had the absolute pleasure of speaking at ...

We end up with:

{"markup":"\u003Cp\u003ETwo weeks ago, I had the absolute pleasure of speaking at ...

It doesn't seem to cause any issues, but wanted to flag in case this jumps out as a concern.

Testing

I've been working with a customer database that I could share, but I would expect this would be an issue you could see if you follow these steps:

  • With Umbraco 13, create a content item that contains a rich text property, with a populated block along with the markup.
  • Attach the database to the latest code from main or release/16.4 and I'd expect you would see the block information lost after Umbraco starts and the migration completes.
  • Repeating with the code from this PR should show the block data retained.

…migration.

Refreshes internal datatype cache following migration requiring cache rebuild.
Copilot AI review requested due to automatic review settings November 19, 2025 10:33
@AndyButland AndyButland changed the title Migrations: Handles rich text blocks created with TinyMCE in convert local links migration and refreshes internal datatype cache following migration requiring cache rebuild. Migrations: Handles rich text blocks created with TinyMCE in convert local links migration and refreshes internal datatype cache following migration requiring cache rebuild (closes #20885) Nov 19, 2025
Copilot finished reviewing on behalf of AndyButland November 19, 2025 10:35
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 two critical issues encountered during Umbraco 13 to 16+ migrations: preserving rich text blocks created with TinyMCE and ensuring internal datatype caches are properly refreshed after migrations.

Key Changes:

  • Extended RichTextBlockValue to recognize the legacy "Umbraco.TinyMCE" property editor alias alongside the current "Umbraco.RichText" alias, preventing data loss during the ConvertLocalLinks migration
  • Added ClearDataTypeCache() method to IPublishedContentTypeFactory and its implementation to clear internal datatype caches post-migration
  • Updated MigrationPlanExecutor to call the new cache clearing method after rebuilding caches

Reviewed Changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
src/Umbraco.Core/Models/Blocks/RichTextBlockValue.cs Overrides SupportsBlockLayoutAlias() to accept both "Umbraco.RichText" and "Umbraco.TinyMCE" aliases for backward compatibility
src/Umbraco.Core/Models/PublishedContent/IPublishedContentTypeFactory.cs Adds ClearDataTypeCache() method with default no-op implementation to avoid breaking existing mock implementations
src/Umbraco.Core/Models/PublishedContent/PublishedContentTypeFactory.cs Implements ClearDataTypeCache() with proper thread-safety using the existing lock mechanism
src/Umbraco.Infrastructure/Migrations/MigrationPlanExecutor.cs Adds obsolete constructor that chains to new constructor using StaticServiceProvider, adds new constructor parameter for IPublishedContentTypeFactory, and calls ClearDataTypeCache() during cache rebuild
tests/Umbraco.Tests.UnitTests/Umbraco.Core/PropertyEditors/RichTextPropertyEditorHelperTests.cs Parameterizes test to verify parsing works with both "Umbraco.RichText" and "Umbraco.TinyMCE" property editor aliases
tests/Umbraco.Tests.UnitTests/Umbraco.Infrastructure/Migrations/MigrationPlanTests.cs Updates test to provide mocked IPublishedContentTypeFactory to new constructor
tests/Umbraco.Tests.Integration/Umbraco.Infrastructure/Migrations/AdvancedMigrationTests.cs Updates integration test to provide real IPublishedContentTypeFactory instance to new constructor

Copy link
Contributor

@kjac kjac left a comment

Choose a reason for hiding this comment

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

Works like a charm 👍

@kjac kjac merged commit a488d77 into main Nov 19, 2025
32 of 33 checks passed
@kjac kjac deleted the v17/bugfix/handle-tinymce-blocks-in-migration branch November 19, 2025 13:54
AndyButland added a commit that referenced this pull request Nov 19, 2025
…local links migration and refreshes internal datatype cache following migration requiring cache rebuild (closes #20885) (#20887)

Handles rich text blocks created with TinyMCE in convert local links migration.
Refreshes internal datatype cache following migration requiring cache rebuild.
AndyButland added a commit that referenced this pull request Nov 19, 2025
…local links migration and refreshes internal datatype cache following migration requiring cache rebuild (closes #20885) (#20887)

Handles rich text blocks created with TinyMCE in convert local links migration.
Refreshes internal datatype cache following migration requiring cache rebuild.
# Conflicts:
#	src/Umbraco.Infrastructure/Migrations/MigrationPlanExecutor.cs
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants