Problem/Motivation

ModuleUninstallValidatorInterface services are the recommended way (see https://www.drupal.org/node/2392677) to prevent uninstalling a module if there are e.g. config dependencies that should avoid uninstalling the module.

However, we lack something similar for themes, while e.g. config can depend on themes and we might want to prevent uninstalling them.

Proposed resolution

Add ThemeUninstallValidatorInterface similar to ModuleUninstallValidatorInterface.
Evaluate if we can refactor ModuleUninstallValidatorInterface to use a common ExtensionUninstallValidatorInterface.

Remaining tasks

TBD

User interface changes

TBD

Introduced terminology

TBD

API changes

TBD

Data model changes

TBD

Release notes snippet

TBD

Issue fork drupal-3550019

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

penyaskito created an issue. See original summary.

wim leers’s picture

The absence of this is causing all config that depends on the theme to be deleted without warning! For module uninstallations causing config to be deleted, a detailed confirmation dialog is presented. The same should happen for theme uninstallations.

nicxvan’s picture

So SDC's are available at all times if a theme is enabled, even if it's not in the active theme context?

Conceptually this makes sense if someone wants to start working on an MR.

var17 made their first commit to this issue’s fork.

cilefen’s picture

Could we rebrand it as ExtensionUninstallValidatorInterface?

nicxvan’s picture

@cilefen good idea, but I don't think we want to do that.

Module and theme uninstall are different enough I think we want to keep these separate.

I'm not 100% convinced myself so if you have further thoughts please share.

catch’s picture

Category: Feature request » Task
Priority: Normal » Critical

The absence of this is causing all config that depends on the theme to be deleted without warning!

Not really a normal feature request then, bumping to critical.

longwave’s picture

As far as I can see the request here doesn't need a ThemeUninstallValidatorInterface, as this isn't done via an uninstall validator for modules.

ModuleUninstallConfirmForm::buildForm() shows the dependent entities:

    // List the dependent entities.
    $this->addDependencyListsToForm($form, 'module', $this->modules, $this->configManager, $this->entityTypeManager);

There is no such confirmation page for uninstalling a theme - a theme can be uninstalled from /admin/appearance with just a CSRF token.

longwave’s picture

Which means this is probably a duplicate of #3096170: Add Confirmation Page for theme uninstall?

Version: 11.x-dev » main

Drupal core is now using the main branch as the primary development branch. New developments and disruptive changes should now be targeted to the main branch.

Read more in the announcement.

longwave’s picture

Status: Active » Postponed (maintainer needs more info)
nicxvan’s picture

Aren't the validators about adding rules around uninstall? We need both right?

longwave’s picture

Well, we at least need the confirmation page first before we can even validate the uninstall I think? But module dependencies aren't handled through an uninstall validator anyway from what I saw.

nicxvan’s picture

Well, we at least need the confirmation page first before we can even validate the uninstall I think

Yes, I think that is accurate!

But module dependencies aren't handled through an uninstall validator anyway from what I saw

My understanding is that it's just for checking a condition that has to pass before moduleUninstall is allowed.
This is for things beyond just module dependencies. For example the field module has one to prevent it's uninstall if there are still fields pending deletion.

longwave’s picture

But is there any concrete use case for this for themes? So far I've only seen config dependencies requested, and the uninstall confirmation issue already handles that.

nicxvan’s picture

You're most likely right, I could see some distros wanting to do this to prevent uninstall entirely, but you can still change defaults.

We can leave this pmni for a bit for feedback and close it if the confirmation page works.

nicxvan’s picture

Status: Postponed (maintainer needs more info) » Closed (outdated)

I think it's safe to close this, the confirmation page has been in for a couple of months and it provides a dialog about the config.

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.