Skip to content

Conversation

@Shazwazza
Copy link
Contributor

Without this being public it is not possible to override anything or resolve this internally without some ugly reflection being done at the composition layer. ExamineX has had to copy this internally to override some methods since index rebuilding should not be done for certain server roles. Similarly, for persisted indexes in managed search services like ExamineX with Azure or Elasticsearch, rebuilding on cold boot should not be done so this behavior needs to be overridden.

Without this being public it is not possible to override anything or resolve this internally without some ugly reflection being done at the composition layer. ExamineX has had to copy this internally to override some methods since index rebuilding should not be done for certain server roles. Similarly, for persisted indexes in managed search services like ExamineX with Azure or Elasticsearch, rebuilding on cold boot should not be done so this behavior needs to be overridden.
Copilot AI review requested due to automatic review settings December 2, 2025 21:17
Copilot finished reviewing on behalf of Shazwazza December 2, 2025 21:22
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 changes the ExamineIndexRebuilder class from internal to public access modifier to enable extensibility for packages like ExamineX that need to override index rebuilding behavior for specific scenarios (e.g., certain server roles or persisted indexes in managed search services).

Key Changes

  • Changed access modifier of ExamineIndexRebuilder class from internal to public

namespace Umbraco.Cms.Infrastructure.Examine;

internal class ExamineIndexRebuilder : IIndexRebuilder
public class ExamineIndexRebuilder : IIndexRebuilder
Copy link

Copilot AI Dec 2, 2025

Choose a reason for hiding this comment

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

Making the class public is insufficient for proper extensibility. The private methods CanRun(), RebuildIndex(string, TimeSpan, CancellationToken), RebuildIndexes(bool, TimeSpan, CancellationToken), and ShouldRebuild(IIndex) should also be changed to protected virtual to allow derived classes to override the rebuild behavior. Without this, developers cannot override critical rebuild logic for scenarios like excluding certain server roles or handling persisted indexes in managed search services as mentioned in the PR description.

Copilot uses AI. Check for mistakes.
Copy link
Contributor Author

Choose a reason for hiding this comment

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

That is unnecessary, by implementing the IIndexRebuilder and explicitly implementing any methods on that interface will effectively override the members on the base class, no need to declare virtual.

@AndyButland
Copy link
Contributor

Could you just share a little more why you need this public @Shazwazza please, given it sounds like you are having to provide a custom implementation of IIndexRebuilder anyway? If there's good reason to make this public I'm not against doing it, but, as you'll know, generally the preference is to keep implementations internal and interfaces public.

@Shazwazza
Copy link
Contributor Author

@AndyButland sure thing - I've had to copy this class locally to ExamineX just so that I can override some methods to ensure things don't happen depending on a few things:

  • If the current IExamineManager is in fact the ExamineX one and...
  • if the server role is ServerRole.Subscriber, then ignore the rebuild request
  • If its a ColdBoot and don't ever rebuild empty indexes - since they are hosted in cloud services
  • to apply a FilteredExamineManager so that both local and hosted indexes work simultaneously if configured that way

Its specific to ExamineX or potentially other Examine implementations where the indexes are not local lucene file based.

If this was public, then I can override the methods I need by just explicitly implementing the interface members I want to override.

I can look at incorporating a Decorator extension method to basically do the same thing. Happy to try that out first and will report back.

@AndyButland
Copy link
Contributor

OK, thanks @Shazwazza - give that a try and let me know. If it's a problem though do come back - this was public before so it wouldn't be a huge issue to make it so again; but it had been obsoleted/marked as going to be internal for a while, so we made this update for 17.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants