Skip to content

DataLocalization admin page throws when OrchardCore.AdminMenu is disabled #19828

Description

@giannik

Data Localization admin pages fail when Admin Menu is disabled

Describe the bug

When OrchardCore.DataLocalization is enabled and OrchardCore.AdminMenu is disabled, /Admin/DataLocalization/Index—along with every other action on the Data Localization AdminController—returns HTTP 500:

InvalidOperationException: Unable to resolve service for type
'OrchardCore.AdminMenu.Services.IAdminMenuAccessor' while attempting to activate
'OrchardCore.Contents.Services.ContentTypesAdminNodeDataLocalizationProvider'.
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteFactory.CreateArgumentCallSites(...)

Cause

src/OrchardCore.Modules/OrchardCore.Contents/Startup.cs gates all three data-localization providers on OrchardCore.DataLocalization only:

[RequireFeatures("OrchardCore.DataLocalization")]
public sealed class DataLocalizationStartup : StartupBase
{
    public override void ConfigureServices(IServiceCollection services)
    {
        services.AddScoped<ILocalizationDataProvider, ContentTypeDataLocalizationProvider>();
        services.AddScoped<ILocalizationDataProvider, ContentFieldDataLocalizationProvider>();
        services.AddScoped<ILocalizationDataProvider, ContentTypesAdminNodeDataLocalizationProvider>();
    }
}

The third provider, Services/ContentTypesAdminNodeDataLocalizationProvider.cs, derives from AdminNodeDataLocalizationProvider and requires IAdminMenuAccessor in its constructor.

That service is registered only by the OrchardCore.AdminMenu module’s startup:

services.AddScoped<IAdminMenuAccessor, AdminMenuAccessor>();

OrchardCore.Contents does not depend on OrchardCore.AdminMenu, nor should it.

Because the Data Localization AdminController takes IEnumerable<ILocalizationDataProvider> in its constructor, one unresolvable provider prevents the entire controller from being activated.

Steps to reproduce

  1. Set up a tenant with:

    • OrchardCore.Contents enabled
    • OrchardCore.DataLocalization enabled
    • OrchardCore.AdminMenu disabled

    This is the default state for a tenant that has never used custom admin menus.

  2. Open /Admin/DataLocalization/Index (ConfigurationData Localization).

  3. Observe the exception above.

Enabling OrchardCore.AdminMenu makes the page render successfully, confirming the missing-feature dependency.

Expected behavior

The Data Localization page should list the content-type and content-field providers. The admin-node provider should participate only when the OrchardCore.AdminMenu feature is enabled.

Proposed fix

Register the admin-node provider under a startup that requires both features.

RequireFeaturesAttribute accepts params string[], and the same file already contains a startup gated on OrchardCore.AdminMenu (AdminMenuStartup). The smallest change appears to be:

[RequireFeatures("OrchardCore.DataLocalization")]
public sealed class DataLocalizationStartup : StartupBase
{
    public override void ConfigureServices(IServiceCollection services)
    {
        services.AddScoped<ILocalizationDataProvider, ContentTypeDataLocalizationProvider>();
        services.AddScoped<ILocalizationDataProvider, ContentFieldDataLocalizationProvider>();
    }
}

[RequireFeatures("OrchardCore.DataLocalization", "OrchardCore.AdminMenu")]
public sealed class AdminMenuDataLocalizationStartup : StartupBase
{
    public override void ConfigureServices(IServiceCollection services)
    {
        services.AddScoped<ILocalizationDataProvider, ContentTypesAdminNodeDataLocalizationProvider>();
    }
}

This would not change behavior for tenants with both features enabled.

Environment

  • Orchard Core 4.0.0-preview

    • Observed on preview-20119
    • The registration is unchanged on main as of today
  • .NET 10

  • Windows 11

  • SQLite (the tenant database is irrelevant to the bug)

  • Reproduced on three tenants with different default cultures (en and el)

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions