Problem/Motivation

From #2659940-119: Extension System, Part III: ThemeExtensionList and ThemeEngineExtensionList:

Starting to feel like these might need to be tagged services with a collector to clear them all in one go? That would be the path to deprecating system_list_reset right? Follow up?

Currently, there is no easy way for code to request all extension listing services. This leads to bloated and hardcoded functions in core that repeatedly list out all known extension listing services (module, theme, theme_engine, profile).

It also leads to bloated and hard to maintain code in contrib modules that need to support additional features, such as added YAML library config or module config.

Proposed resolution

Remaining tasks

User interface changes

API changes

Data model changes

Issue fork drupal-2973439

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

dawehner created an issue. See original summary.

dawehner’s picture

Version: 8.6.x-dev » 8.7.x-dev

Drupal 8.6.0-alpha1 will be released the week of July 16, 2018, which means new developments and disruptive changes should now be targeted against the 8.7.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.7.x-dev » 8.8.x-dev

Drupal 8.7.0-alpha1 will be released the week of March 11, 2019, which means new developments and disruptive changes should now be targeted against the 8.8.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.8.x-dev » 8.9.x-dev

Drupal 8.8.0-alpha1 will be released the week of October 14th, 2019, which means new developments and disruptive changes should now be targeted against the 8.9.x-dev branch. (Any changes to 8.9.x will also be committed to 9.0.x in preparation for Drupal 9’s release, but some changes like significant feature additions will be deferred to 9.1.x.). For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

Version: 8.9.x-dev » 9.1.x-dev

Drupal 8.9.0-beta1 was released on March 20, 2020. 8.9.x is the final, long-term support (LTS) minor release of Drupal 8, which means new developments and disruptive changes should now be targeted against the 9.1.x-dev branch. For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

Version: 9.1.x-dev » 9.2.x-dev

Drupal 9.1.0-alpha1 will be released the week of October 19, 2020, which means new developments and disruptive changes should now be targeted for the 9.2.x-dev branch. For more information see the Drupal 9 minor version schedule and the Allowed changes during the Drupal 9 release cycle.

Version: 9.2.x-dev » 9.3.x-dev

Drupal 9.2.0-alpha1 will be released the week of May 3, 2021, which means new developments and disruptive changes should now be targeted for the 9.3.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.3.x-dev » 9.4.x-dev

Drupal 9.3.0-rc1 was released on November 26, 2021, which means new developments and disruptive changes should now be targeted for the 9.4.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.4.x-dev » 9.5.x-dev

Drupal 9.4.0-alpha1 was released on May 6, 2022, which means new developments and disruptive changes should now be targeted for the 9.5.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.5.x-dev » 10.1.x-dev

Drupal 9.5.0-beta2 and Drupal 10.0.0-beta2 were released on September 29, 2022, which means new developments and disruptive changes should now be targeted for the 10.1.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 10.1.x-dev » 11.x-dev

Drupal core is moving towards using a “main” branch. As an interim step, a new 11.x branch has been opened, as Drupal.org infrastructure cannot currently fully support a branch named main. New developments and disruptive changes should now be targeted for the 11.x branch, which currently accepts only minor-version allowed changes. For more information, see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

andypost’s picture

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

longwave’s picture

Title: Make extension services tagged services » Make extension list services tagged services
Status: Active » Needs review

Unsure if or how to provide BC in the constructor here, but I also don't see why anyone would override this. This issue helps unblock #1685492: Convert theme engines into services where the theme engine list will be deprecated.

Not actually sure these are all cleared anywhere any more, we could add something to the resolver to clear them if necessary but it feels like the wrong place.

nicxvan’s picture

Do you mean where reset is called? https://git.drupalcode.org/project/drupal/-/blob/11.x/core/lib/Drupal/Co...

I was actually looking into that a couple of weeks ago when I thought I needed to reset themes.

Let me look again iirc it was called somewhere for modules but not the other extension lists.

Maybe like this: https://git.drupalcode.org/project/drupal/-/blob/11.x/core/lib/Drupal/Co...

And here: https://git.drupalcode.org/project/drupal/-/blob/11.x/core/lib/Drupal/Co...
And here:
https://git.drupalcode.org/project/drupal/-/blob/11.x/core/lib/Drupal/Co...

longwave’s picture

Yeah it's not clear in many cases if we should be resetting one, some, or all. Not sure if we need to mess with any of that here though, if there are no known bugs; in practice the lists do not change often.

nicxvan’s picture

I think this is good, but there are a few open questions for me that I'm trying to answer.

1. Were Database extensions intentionally left out? I know they are super weird and always there like theme engines and I know a lot of the list service is intentionally not implemented. I might ping @daffie and @mondrake just to confirm.
2. BC, I tend to agree, nothing we can do without just wholesale deprecation and replacement which I don't think serves any purpose.

I found where it was implemented: #3256642: Introduce database driver extensions and autoload database drivers' dependencies and there is no mention of the path resolver so I think it was just an oversight rather than intentional.

So for 1, I will ping them, for 2 I will ask for other opinions in slack too.

mondrake’s picture

@nixvan as far as I remember, the db driver related implementation was just the minimum necessary to fill the needs of listing them as extensions in the install process. So yes, all what was not necessary was intentionally left out, if that's what you mean.

nicxvan’s picture

Status: Needs review » Needs work

Thanks @mondrake! That solves concern 1.

I have two minor doc updates as MR suggestions.

I think there is nothing to do for BC here. Once we get those two comments applied I can RTBC I think.

Does this need a CR? Technically it's a BC break, but I don't think it will be for most people using it.

longwave’s picture

Status: Needs work » Needs review

Fixed up the docs, removed database drivers for now, and I wrote a basic change record at https://www.drupal.org/node/3549907

nicxvan’s picture

Status: Needs review » Reviewed & tested by the community

CR and changes look good, only open question is if there is a way to do this and preserve BC. I think this is fine as is though.

alexpott’s picture

Status: Reviewed & tested by the community » Needs work
Issue tags: +Needs issue summary update

Are we sure that we want to do this? This feels like we creating way to extend extension listing. I think the issue summary needs an update to explain the motivation amongst other things.

nicxvan’s picture

Copied from a duplicate to the issue summary.

nicxvan’s picture

Status: Needs work » Needs review

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

dcam’s picture

Status: Needs review » Needs work

So, the change to ExtensionPathResolver is just to verify the service tag works, right? It would be nice to have that in the proposed resolution section of the issue summary.

Here's your BC example:

  public function __construct(
    #[AutowireLocator('extension_list', 'type')]
    protected ContainerInterface|ModuleExtensionList $extensionLists,
  ) {
    if ($this->extensionLists instanceof ModuleExtensionList) {
      @trigger_error('Calling ' . __CLASS__ . '::_construct() with a ModuleExtensionList as the first parameter is deprecated in drupal:11.4.0 and is removed from drupal:12.0.0. ::__construct() must be called with a single ContainerInterface parameter. See CHANGE_RECORD_URL.', E_USER_DEPRECATED);
      $this->extensionLists = new ContainerBuilder();
      $this->extensionLists->set('module', \Drupal::service('extension.list.module'));
      $this->extensionLists->set('profile', \Drupal::service('extension.list.profile'));
      $this->extensionLists->set('theme', \Drupal::service('extension.list.theme'));
      $this->extensionLists->set('theme_engine', \Drupal::service('extension.list.theme_engine'));
    }
  }

My limited testing showed that it worked. Basically, I reverted the change to ExtensionPathResolverTest and also added a new test function to it that requested the path for the system module. You'll probably need to workshop the deprecation message. I hope you don't mind if I set the issue to Needs Work for you to consider it. I agree that it's probably pointless, but I was so hesitant to review this without BC.

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.