Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
101 commits
Select commit Hold shift + click to select a range
779242f
chore: make indexing more resiliant
bielu1 Jun 3, 2024
ad5ccef
POC: add populator information to reindex model
bielu Jun 15, 2024
eb97962
Render folders before files in static files picker. (#18701)
AndyButland Mar 18, 2025
5570583
Fixes issue with macro rendering in an RTE when GUIDs are used for ba…
AndyButland Mar 18, 2025
68acc2a
Bumped version to 13.9.0-rc.
AndyButland Mar 19, 2025
eb91f4f
Make preview check for delivery API content case insensitive. (#18731)
AndyButland Mar 20, 2025
9284b9e
Make preview check for delivery API content case insensitive. (#18731)
AndyButland Mar 20, 2025
42a81be
V13 hotfix sqlserver integration tests (#18744)
andr317c Mar 20, 2025
fdca086
build(deps): bump @umbraco-ui/uui from 1.12.2 to 1.13.0 (#18830)
iOvergaard Mar 26, 2025
05a7d33
Check we have matched a preview URL by ID when exiting preview. (#18841)
AndyButland Apr 3, 2025
3e9ff6b
Check we have matched a preview URL by ID when exiting preview. (#18841)
AndyButland Apr 3, 2025
d60a2a2
Verify endpoint selection candidates with host attribute are ignored …
AndyButland Apr 3, 2025
a3db456
Move database cache rebuild to a background task with polling (13) (#…
AndyButland Apr 3, 2025
0f02584
attempted fix for Datepicker v13 issue #16008 (#18903)
Navya-Sinhaa Apr 4, 2025
0e0aca5
Verify endpoint selection candidates with host attribute are ignored …
AndyButland Apr 3, 2025
3c8a621
Merge branch 'v13/dev' into v13/contrib
AndyButland Apr 4, 2025
a486d5d
Bumped version to 13.8.0.
AndyButland Apr 10, 2025
7d9a2c6
Merge branch 'release/13.8.0' into v13/dev
AndyButland Apr 10, 2025
ab31fbb
Bump version to 13.8.1.
AndyButland Apr 17, 2025
c6effef
Handle file paths as not found in delivery API by route requests (#19…
AndyButland Apr 22, 2025
afa6fa5
attempted fix for Save and Preview button #15360 (#19138)
Navya-Sinhaa Apr 25, 2025
a22dcf0
Merge branch 'v13/contrib' into v13/dev
AndyButland Apr 28, 2025
a62fa93
Use windows agent for nuget push
nikolajlauridsen Apr 28, 2025
097d045
V13 QA updated pipeline for acceptance to avoid issue when installing…
andr317c Apr 29, 2025
8d85259
Upgrade examine to 3.7.1 (#19186)
dawoe Apr 29, 2025
d499655
Merge branch 'v13/contrib' into v13/dev
AndyButland Apr 29, 2025
1efe860
V13: Clear Member Username Cache in Load Balanced Environments (#19191)
nikolajlauridsen Apr 29, 2025
3caa43a
Fix root path regression for the Delivery API (#19216)
kjac May 3, 2025
83107bb
Fix: #18421 - Added Max Length validation to PropertyTypeBasic Alias …
danielhnelson May 5, 2025
34709be
Merge commit from fork
AndyButland May 6, 2025
e94e165
Fixed pipeline definition.
AndyButland May 6, 2025
dcbbed4
Fixed failures in unit tests.
AndyButland May 6, 2025
5ba40c6
Merge branch 'release/13.8.1' into v13/dev
AndyButland May 6, 2025
643f073
`TimedScope` improvements and login duration clean-up (#19243)
ronaldbarendse May 7, 2025
6a4aa04
Handle existing RichTextEditorValue when parsing from markup or JSON …
AndyButland May 8, 2025
0eee307
Added custom RichTextRegexValidator to validate markup instead of JSO…
tomvanenckevort May 8, 2025
3d44a6f
Invalidate external login session on removal of provider (#19273)
AndyButland May 9, 2025
c0a0a34
Backport variable name updates and fix found porting the invalidation…
AndyButland May 9, 2025
0fb91ef
add single blocklist delete (#18073)
Migaroez May 12, 2025
e471c1f
[V13] User notifications not sent correctly when having more than 400…
May 13, 2025
0597662
Fix for block grid styling regression issue #15973 (#19014)
Lili-Rossiter May 13, 2025
4f1604f
V13/bugfix/partial cache (#19314)
Migaroez May 14, 2025
6c2f93e
V13 QA Updated linux test images to match actual (#19309)
andr317c May 14, 2025
0fc5b2a
Avoids unnecessary additional domain save notification publishing whe…
AndyButland May 14, 2025
87b2153
Adds support for retrieval of data type references when data type is …
AndyButland May 14, 2025
8433b2b
User invite email fails if visited more than once without completing …
dchallener May 14, 2025
7d6a1e5
Optimize the member save as part of the member login process, by-pass…
AndyButland May 20, 2025
127c6c4
Optimize the member save as part of the member login process, by-pass…
AndyButland May 20, 2025
eee04f4
fix: check for NullRepresentationInCache in AppCacheExtensions (#19350)
AndyButland May 22, 2025
5556b0f
Fixed check for navigation to list after delete of member (#19364)
AndyButland May 22, 2025
c609caf
Fixed check for navigation to list after delete of member (#19364)
AndyButland May 22, 2025
d4e6af5
Merge branch 'release/13.9' into v13/dev
AndyButland May 22, 2025
d677e94
Fix issue with requests to delivery API by path where URL segment con…
AndyButland May 23, 2025
4d8ca45
Removes unnecessary newlines from rich text as JSON delivery API outp…
AndyButland May 23, 2025
7f4a8d5
Merge branch 'v13/dev' into v13/main
AndyButland May 27, 2025
b348b84
Lock appropriate tree for media operations (#19422)
rbottema May 27, 2025
4b83a74
Resolved exception thrown from NuCache locking mechanism on near-simu…
AndyButland May 28, 2025
ebd228c
Ensure tag operations are case insensitive on insert across database …
AndyButland May 30, 2025
0bcae3e
Fix null member edgecase (#19463)
Migaroez Jun 3, 2025
97cc3ca
Bumped version to 13.9.0.
AndyButland Jun 5, 2025
1d6e7f1
Bumped version to 13.9.1.
AndyButland Jun 5, 2025
a01382d
Merge branch 'release/13.9' into v13/dev
AndyButland Jun 5, 2025
28570b4
Fix issues with removal of user logins on change to external login pr…
AndyButland Jun 10, 2025
f6dbe0f
Bumped version to 13.9.2.
AndyButland Jun 10, 2025
e1b9e5e
Merge branch 'release/13.9.1' into v13/dev
AndyButland Jun 10, 2025
1e66fb6
Add a warning to the `CreateContentFromBlueprint` method xml docs (#1…
lauraneto Jun 13, 2025
881535a
Merge branch 'v13/dev' into v13/main
AndyButland Jun 13, 2025
4ad18dc
Preserve word boundaries when indexing RTE content with <br> tags (#1…
steveatkiss Jun 23, 2025
b414456
Merge commit from fork
kjac Jun 24, 2025
1f5c21c
Fix pagination in Content Delivery API Index Helper (#19606)
Brynjarth Jul 1, 2025
990e379
Ensures that null values aren't used to create a CompositeStringStrin…
AndyButland Jul 1, 2025
fd95dc3
Merge branch 'release/13.9.2' into v13/dev
AndyButland Jul 2, 2025
a60ccd3
#16772 partial fix backoffice redirect after login (#19663)
kows Jul 7, 2025
13a2cd7
Clear member cache by older user name when member user name is update…
AndyButland Jul 7, 2025
53cc663
Register no-op implementation of IMemberPartialViewCacheInvalidator i…
AndyButland Jul 8, 2025
2748fdf
Adds variation by the header name Accept-Language to the delivery API…
AndyButland Jul 11, 2025
ce40103
Add support for programmatic creation of property types providing the…
AndyButland Jul 15, 2025
417f151
Parse update date before sorting in media list view (#19711)
AndyButland Jul 16, 2025
ebd0017
Bumped version to 13.9.3.
AndyButland Jul 21, 2025
67abecc
Add defensive coding to the member application initializer (#19760)
kjac Jul 21, 2025
59ad072
Retrieve only user external logins when invalidate following removal …
AndyButland Jul 22, 2025
22f7481
Bumped version to 13.11.0-rc.
AndyButland Jul 22, 2025
509a2e1
The filter param should be urlencoded (#19774)
AaronSadlerUK Jul 23, 2025
0d94f8b
Fix issue with use of EF Core scopes within notification handlers (ta…
Migaroez Jul 25, 2025
9f37db1
Merge commit from fork
AndyButland Jul 29, 2025
8eff28b
Merge branch 'release/13.9.3' into v13/dev
AndyButland Jul 29, 2025
a352c42
Merge branch 'release/13.9.3' into release/13.10
AndyButland Jul 29, 2025
b622e7e
Content picker search with start node configured not taking user star…
lauraneto Aug 1, 2025
214f3fb
Umbraco Engage UmbracoUrlAlias Fix - Fixes #19654 (#19827)
cornehoskam Aug 4, 2025
784e09e
Use a regex to filter our invalid culture codes rather than relying o…
AndyButland Aug 6, 2025
c2890e1
Bumped version to 13.10.0
AndyButland Aug 14, 2025
33e201c
Merge branch 'release/13.10' into v13/dev
AndyButland Aug 14, 2025
85aa6d3
Add Arabic (ar) backoffice translation (#19896)
tarikrital Aug 15, 2025
45f7b7a
Retain original backoffice location on login after timeout (#19984)
AndyButland Sep 15, 2025
60f84f7
Support querystring and anchor for local links in Delivery API output
kjac Sep 15, 2025
fe358b8
Merge branch 'v13/bugfix/18475-locallinks-parsing' of https://github.…
AndyButland Sep 16, 2025
a282002
Support querystring and anchor for local links in Delivery API output…
kjac Sep 16, 2025
e119186
Avoid throwing an exception on getting references when migrating cont…
AndyButland Sep 16, 2025
7c180f6
Merge branch 'v13/dev' of https://github.com/umbraco/Umbraco-CMS into…
AndyButland Sep 16, 2025
301be35
Make notification service able to handle segmented content (#20160)
kjac Sep 17, 2025
37e6d1e
Merge branch 'v13/dev' into feat/make-indexing-more-resiliant
nielslyngsoe Sep 17, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions src/Umbraco.Core/Configuration/Models/IndexingSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,8 @@ public class IndexingSettings
/// </summary>
[DefaultValue(StaticExplicitlyIndexEachNestedProperty)]
public bool ExplicitlyIndexEachNestedProperty { get; set; } = StaticExplicitlyIndexEachNestedProperty;
/// <summary>
/// Defines how many items to index in a single page
/// </summary>
public int IndexingPageSize { get; set; } = 10000;
}
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ public static IUmbracoBuilder AddExamine(this IUmbracoBuilder builder)
builder.Services.AddUnique<IDeliveryApiContentIndexFieldDefinitionBuilder, DeliveryApiContentIndexFieldDefinitionBuilder>();
builder.Services.AddUnique<IDeliveryApiContentIndexHelper, DeliveryApiContentIndexHelper>();
builder.Services.AddSingleton<IDeliveryApiIndexingHandler, DeliveryApiIndexingHandler>();

builder.Services.AddSingleton<IIndexRebuildStatusManager, IndexRebuildStatusManager>();
builder.Services.AddSingleton<ExamineIndexRebuilder>(); //TODO remove in Umbraco 15. Only the interface should be in the service provider

builder.Services.AddUnique<IDeliveryApiCompositeIdHandler, DeliveryApiCompositeIdHandler>();
Expand Down
45 changes: 41 additions & 4 deletions src/Umbraco.Infrastructure/Examine/ContentIndexPopulator.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
using Examine;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Options;
using Umbraco.Cms.Core.Configuration.Models;
using Umbraco.Cms.Core.DependencyInjection;
using Umbraco.Cms.Core.Models;
using Umbraco.Cms.Core.Persistence.Querying;
using Umbraco.Cms.Core.Services;
Expand All @@ -14,6 +18,7 @@ public class ContentIndexPopulator : IndexPopulator<IUmbracoContentIndex>
{
private readonly IContentService _contentService;
private readonly IValueSetBuilder<IContent> _contentValueSetBuilder;
private IndexingSettings _indexingSettings;
private readonly ILogger<ContentIndexPopulator> _logger;
private readonly int? _parentId;

Expand All @@ -28,6 +33,7 @@ public class ContentIndexPopulator : IndexPopulator<IUmbracoContentIndex>
/// <summary>
/// Default constructor to lookup all content data
/// </summary>
[Obsolete("Use the constructor with IOptionsMonitor<IndexingSettings>")]
public ContentIndexPopulator(
ILogger<ContentIndexPopulator> logger,
IContentService contentService,
Expand All @@ -40,13 +46,14 @@ public ContentIndexPopulator(
/// <summary>
/// Optional constructor allowing specifying custom query parameters
/// </summary>
[Obsolete("Use the constructor with IOptionsMonitor<IndexingSettings>")]
public ContentIndexPopulator(
ILogger<ContentIndexPopulator> logger,
bool publishedValuesOnly,
int? parentId,
IContentService contentService,
IUmbracoDatabaseFactory umbracoDatabaseFactory,
IValueSetBuilder<IContent> contentValueSetBuilder)
IValueSetBuilder<IContent> contentValueSetBuilder) : this(logger, publishedValuesOnly, parentId, contentService, umbracoDatabaseFactory, contentValueSetBuilder, StaticServiceProvider.Instance.GetRequiredService<IOptionsMonitor<IndexingSettings>>())
{
_contentService = contentService ?? throw new ArgumentNullException(nameof(contentService));
_umbracoDatabaseFactory = umbracoDatabaseFactory ?? throw new ArgumentNullException(nameof(umbracoDatabaseFactory));
Expand All @@ -55,7 +62,37 @@ public ContentIndexPopulator(
_publishedValuesOnly = publishedValuesOnly;
_parentId = parentId;
}
public ContentIndexPopulator(
ILogger<ContentIndexPopulator> logger,
IContentService contentService,
IUmbracoDatabaseFactory umbracoDatabaseFactory,
IContentValueSetBuilder contentValueSetBuilder,
IOptionsMonitor<IndexingSettings> indexingSettings)
: this(logger, false, null, contentService, umbracoDatabaseFactory, contentValueSetBuilder,indexingSettings)
{
}
public ContentIndexPopulator(
ILogger<ContentIndexPopulator> logger,
bool publishedValuesOnly,
int? parentId,
IContentService contentService,
IUmbracoDatabaseFactory umbracoDatabaseFactory,
IValueSetBuilder<IContent> contentValueSetBuilder,
IOptionsMonitor<IndexingSettings> indexingSettings)
{
_contentService = contentService ?? throw new ArgumentNullException(nameof(contentService));
_umbracoDatabaseFactory = umbracoDatabaseFactory ?? throw new ArgumentNullException(nameof(umbracoDatabaseFactory));
_contentValueSetBuilder = contentValueSetBuilder ?? throw new ArgumentNullException(nameof(contentValueSetBuilder));
_indexingSettings = indexingSettings.CurrentValue;
indexingSettings.OnChange(change =>
{
_indexingSettings = change;
});
_logger = logger ?? throw new ArgumentNullException(nameof(logger));
_publishedValuesOnly = publishedValuesOnly;
_parentId = parentId;

}
private IQuery<IContent> PublishedQuery => _publishedQuery ??=
_umbracoDatabaseFactory.SqlContext.Query<IContent>().Where(x => x.Published);

Expand All @@ -75,7 +112,7 @@ protected override void PopulateIndexes(IReadOnlyList<IIndex> indexes)
return;
}

const int pageSize = 10000;

var pageIndex = 0;

var contentParentId = -1;
Expand All @@ -86,11 +123,11 @@ protected override void PopulateIndexes(IReadOnlyList<IIndex> indexes)

if (_publishedValuesOnly)
{
IndexPublishedContent(contentParentId, pageIndex, pageSize, indexes);
IndexPublishedContent(contentParentId, pageIndex, _indexingSettings.IndexingPageSize, indexes);
}
else
{
IndexAllContent(contentParentId, pageIndex, pageSize, indexes);
IndexAllContent(contentParentId, pageIndex, _indexingSettings.IndexingPageSize, indexes);
}
}

Expand Down
27 changes: 25 additions & 2 deletions src/Umbraco.Infrastructure/Examine/ExamineIndexRebuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@
// See LICENSE for more details.

using Examine;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
using Umbraco.Cms.Core;
using Umbraco.Cms.Core.DependencyInjection;
using Umbraco.Cms.Core.Runtime;
using Umbraco.Cms.Core.Services;
using Umbraco.Cms.Infrastructure.HostedServices;
Expand All @@ -16,6 +18,7 @@ public class ExamineIndexRebuilder : IIndexRebuilder
private readonly IBackgroundTaskQueue _backgroundTaskQueue;
private readonly IExamineManager _examineManager;
private readonly ILogger<ExamineIndexRebuilder> _logger;
private readonly IIndexRebuildStatusManager _indexRebuildStatusManager;
private readonly IMainDom _mainDom;
private readonly IEnumerable<IIndexPopulator> _populators;
private readonly object _rebuildLocker = new();
Expand All @@ -24,17 +27,29 @@ public class ExamineIndexRebuilder : IIndexRebuilder
/// <summary>
/// Initializes a new instance of the <see cref="ExamineIndexRebuilder" /> class.
/// </summary>
[Obsolete("Use constructor with IIndexRebuildStatusManager. This is scheduled for removal in Umbraco 15.")]
public ExamineIndexRebuilder(
IMainDom mainDom,
IRuntimeState runtimeState,
ILogger<ExamineIndexRebuilder> logger,
IExamineManager examineManager,
IEnumerable<IIndexPopulator> populators,
IBackgroundTaskQueue backgroundTaskQueue) : this(mainDom, runtimeState, logger, StaticServiceProvider.Instance.GetRequiredService<IIndexRebuildStatusManager>(), examineManager, populators, backgroundTaskQueue)
{
}
public ExamineIndexRebuilder(
IMainDom mainDom,
IRuntimeState runtimeState,
ILogger<ExamineIndexRebuilder> logger,
IIndexRebuildStatusManager indexRebuildStatusManager,
IExamineManager examineManager,
IEnumerable<IIndexPopulator> populators,
IBackgroundTaskQueue backgroundTaskQueue)
{
_mainDom = mainDom;
_runtimeState = runtimeState;
_logger = logger;
_indexRebuildStatusManager = indexRebuildStatusManager;
_examineManager = examineManager;
_populators = populators;
_backgroundTaskQueue = backgroundTaskQueue;
Expand Down Expand Up @@ -147,7 +162,7 @@ private void RebuildIndex(string indexName, TimeSpan delay, CancellationToken ca
{
throw new InvalidOperationException($"No index found with name {indexName}");
}

_indexRebuildStatusManager.SetRebuildingIndexStatus([indexName], true);
index.CreateIndex(); // clear the index
foreach (IIndexPopulator populator in _populators)
{
Expand All @@ -158,6 +173,7 @@ private void RebuildIndex(string indexName, TimeSpan delay, CancellationToken ca

populator.Populate(index);
}
_indexRebuildStatusManager.SetRebuildingIndexStatus([indexName], false);
}
}
finally
Expand All @@ -175,6 +191,7 @@ private void RebuildIndexes(bool onlyEmptyIndexes, TimeSpan delay, CancellationT
{
Thread.Sleep(delay);
}
IEnumerable<string>? rebuildedIndex = null;

try
{
Expand All @@ -190,7 +207,8 @@ private void RebuildIndexes(bool onlyEmptyIndexes, TimeSpan delay, CancellationT
? _examineManager.Indexes.Where(x =>
!x.IndexExists() || (x is IIndexStats stats && stats.GetDocumentCount() == 0))
: _examineManager.Indexes).ToArray();

rebuildedIndex = indexes.Select(x => x.Name);
_indexRebuildStatusManager.SetRebuildingIndexStatus(rebuildedIndex, true);
if (indexes.Length == 0)
{
return;
Expand Down Expand Up @@ -218,10 +236,15 @@ private void RebuildIndexes(bool onlyEmptyIndexes, TimeSpan delay, CancellationT
_logger.LogError(e, "Index populating failed for populator {Populator}", populator.GetType());
}
}

}
}
finally
{
if (rebuildedIndex != null && rebuildedIndex.Any())
{
_indexRebuildStatusManager.SetRebuildingIndexStatus(rebuildedIndex, false);
}
if (Monitor.IsEntered(_rebuildLocker))
{
Monitor.Exit(_rebuildLocker);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
namespace Umbraco.Cms.Infrastructure.Examine;

public interface IIndexRebuildStatusManager
{
void SetRebuildingIndexStatus(IEnumerable<string> indexes, bool b);
bool GetRebuildingIndexStatus(string index);
}
28 changes: 28 additions & 0 deletions src/Umbraco.Infrastructure/Examine/IndexRebuildStatusManager.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
using Examine;

namespace Umbraco.Cms.Infrastructure.Examine;

/// <summary>
///
/// </summary>
public class IndexRebuildStatusManager : IIndexRebuildStatusManager
Copy link
Contributor

Choose a reason for hiding this comment

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

My recommended approach would be to do this: Shazwazza/Examine#372 (comment)

The only real way to know if the indexing is done in a resilient way would be to have an actual document in the index certifying that rebuilding is successful instead of relying on in-memory cache which is problematic.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@Shazwazza I am not 100% convinced about usage of additional index, as we both know less indexes is actually better with lucene. I am thinking maybe we should use additonal sql table, as it will be eqally resiliant as using index, but it will not require us to create index, what you think?

Copy link
Contributor

Choose a reason for hiding this comment

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

@bielu Sorry, I probably wasn't clear in my suggestion. We don't want to use an extra index to store any data, we can just use a marker document within the index. For example:

  • Rebuilding an index deletes all data
  • The index is populated with the normal data
  • When the IndexPopulator is done populating the index, it then writes a special marker document signaling that the populator is done. Perhaps this document has a field like __Populated: y

Then the rebuild checker, just checks if the document count for __Populated: y == 1

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@Shazwazza that's make sense now! We can also extend it to check what populator are registered to show how many of them is done! I will make update to this pr

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@Shazwazza i started changing implementation of this service to use examine underhood, can you have quick look and check if that is what you had in mind?
as in this way now we can also repeat failed batches (but i think I will need play around little more)

{
IDictionary<string,bool> _rebuildingStatus = new Dictionary<string, bool>();
public IndexRebuildStatusManager(IExamineManager examineManager)
{
foreach (var index in examineManager.Indexes)
{
_rebuildingStatus.Add(index.Name, false);
}
}

public void SetRebuildingIndexStatus(IEnumerable<string> indexes, bool isRebuilding)
{
foreach (var index in indexes)
{
_rebuildingStatus[index] = isRebuilding;
}
}

public bool GetRebuildingIndexStatus(string index) => _rebuildingStatus.TryGetValue(index, out var isRebuilding) && isRebuilding;
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,11 @@
using Lucene.Net.QueryParsers.Classic;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
using Umbraco.Cms.Core;
using Umbraco.Cms.Core.Cache;
using Umbraco.Cms.Core.DependencyInjection;
using Umbraco.Cms.Core.Models.ContentEditing;
using Umbraco.Cms.Infrastructure.Examine;
using Umbraco.Cms.Web.Common.Attributes;
Expand All @@ -22,23 +24,32 @@ public class ExamineManagementController : UmbracoAuthorizedJsonController
private readonly IExamineManager _examineManager;
private readonly IIndexDiagnosticsFactory _indexDiagnosticsFactory;
private readonly IIndexRebuilder _indexRebuilder;
private readonly IIndexRebuildStatusManager _rebuildStatusManager;
private readonly ILogger<ExamineManagementController> _logger;
private readonly IAppPolicyCache _runtimeCache;

[Obsolete("Use the ctor with IOptionsMonitor<IIndexRebuildOptions>>")]
public ExamineManagementController(
IExamineManager examineManager,
ILogger<ExamineManagementController> logger,
IIndexDiagnosticsFactory indexDiagnosticsFactory,
AppCaches appCaches,
IIndexRebuilder indexRebuilder)
IIndexRebuilder indexRebuilder) : this(examineManager, logger, indexDiagnosticsFactory, appCaches, indexRebuilder, StaticServiceProvider.Instance.GetRequiredService<IIndexRebuildStatusManager>())
{
}
public ExamineManagementController(
IExamineManager examineManager,
ILogger<ExamineManagementController> logger,
IIndexDiagnosticsFactory indexDiagnosticsFactory,
AppCaches appCaches,
IIndexRebuilder indexRebuilder, IIndexRebuildStatusManager rebuildStatusManager)
{
_examineManager = examineManager;
_logger = logger;
_indexDiagnosticsFactory = indexDiagnosticsFactory;
_runtimeCache = appCaches.RuntimeCache;
_indexRebuilder = indexRebuilder;
_rebuildStatusManager = rebuildStatusManager;
}

/// <summary>
/// Get the details for indexers
/// </summary>
Expand Down Expand Up @@ -129,11 +140,8 @@ public ActionResult<SearchResults> GetSearchResults(string searcherName, string?
return validate;
}

var cacheKey = "temp_indexing_op_" + indexName;
var found = _runtimeCache.Get(cacheKey);

//if its still there then it's not done
return found != null
return _rebuildStatusManager.GetRebuildingIndexStatus(indexName)
? null
: CreateModel(index!);
}
Expand Down Expand Up @@ -167,12 +175,7 @@ public IActionResult PostRebuildIndex(string indexName)

try
{
var cacheKey = "temp_indexing_op_" + index.Name;
//put temp val in cache which is used as a rudimentary way to know when the indexing is done
_runtimeCache.Insert(cacheKey, () => "tempValue", TimeSpan.FromMinutes(5));

_indexRebuilder.RebuildIndex(indexName);

return new OkResult();
}
catch (Exception ex)
Expand Down Expand Up @@ -307,8 +310,5 @@ private void Indexer_IndexOperationComplete(object? sender, EventArgs e)
}

_logger.LogInformation("Rebuilding index '{indexerName}' done.", indexer?.Name);

var cacheKey = "temp_indexing_op_" + indexer?.Name;
_runtimeCache.Clear(cacheKey);
}
}
1 change: 1 addition & 0 deletions src/Umbraco.Web.UI.New.Client
Submodule Umbraco.Web.UI.New.Client added at c48ede