-
Notifications
You must be signed in to change notification settings - Fork 2.9k
Document URL Cache: Ensure URLs are rebuilt after upgrade and prevent duplicate initialization (closes #21337) #21379
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
AndyButland
merged 3 commits into
main
from
v17/bugfix/ensure-document-urls-rebuilt-on-startup
Jan 21, 2026
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
34 changes: 28 additions & 6 deletions
34
src/Umbraco.Infrastructure/Migrations/Upgrade/V_15_0_0/RebuildDocumentUrls.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,16 +1,38 @@ | ||
| using Umbraco.Cms.Core.Services; | ||
| using Microsoft.Extensions.DependencyInjection; | ||
| using Umbraco.Cms.Core.DependencyInjection; | ||
| using Umbraco.Cms.Core.Services; | ||
|
|
||
| namespace Umbraco.Cms.Infrastructure.Migrations.Upgrade.V_15_0_0; | ||
|
|
||
| [Obsolete("Remove in Umbraco 18.")] | ||
| public class RebuildDocumentUrls : MigrationBase | ||
| { | ||
| private readonly IDocumentUrlService _documentUrlService; | ||
| private readonly IKeyValueService _keyValueService; | ||
|
|
||
| public RebuildDocumentUrls(IMigrationContext context, IDocumentUrlService documentUrlService) | ||
| : base(context) => | ||
| _documentUrlService = documentUrlService; | ||
| : this( | ||
| context, | ||
| documentUrlService, | ||
| StaticServiceProvider.Instance.GetRequiredService<IKeyValueService>()) | ||
AndyButland marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| { | ||
| } | ||
|
|
||
| protected override void Migrate() | ||
| => _documentUrlService.InitAsync(false, CancellationToken.None).GetAwaiter().GetResult(); | ||
| public RebuildDocumentUrls(IMigrationContext context, IDocumentUrlService documentUrlService, IKeyValueService keyValueService) | ||
| : base(context) | ||
| { | ||
| // The documentUrlService parameter is kept for backward compatibility and to maintain | ||
| // constructor signature compatibility with earlier versions/DI registrations. It is not | ||
| // required by this migration, which only needs access to IKeyValueService. | ||
| _ = documentUrlService; | ||
| _keyValueService = keyValueService; | ||
| } | ||
|
|
||
| /// <inheritdoc/> | ||
| protected override void Migrate() => | ||
|
|
||
| // Clear any existing key to force rebuild on first normal startup. | ||
| // This ensures URL generation runs when all services are fully initialized, | ||
| // rather than during migration when variant content data may not be accessible. | ||
| // See: https://github.com/umbraco/Umbraco-CMS/issues/21337 | ||
| _keyValueService.SetValue(DocumentUrlService.RebuildKey, string.Empty); | ||
| } | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.