At admin/structure/plugin/condition I see this plugin:

Vocabulary entity_bundle Chaos tools

But that's a plugin that has a deriver, and so produces a copy for each entity type. It looks like the last entity type in the list is the one that's getting displayed, so maybe there's array key clobbering going on somewhere.

CommentFileSizeAuthor
#2 2767065-01.plugin_list_id.patch1.15 KBekes

Comments

joachim created an issue. See original summary.

ekes’s picture

StatusFileSize
new1.15 KB

It's because ListPlugins::execute() builds an array keyed on the value of $plugin_definition->getId().

Looking at the site where I've just been breaking my head, some modules (facets) have ids that include base_id:derivative_id however others (ctools, system, views) return just base_id.

Now I'd actually like to know, should ctools and views, system (both core) be returning full derivative id from getId() not the base plugin id? Is facets more correct?

Anyway the key doesn't need to be the result of ::getId() because it could just use the key from ::getDefinitions()

xano’s picture

Status: Active » Closed (duplicate)

If a plugin is derived from another, its ID should by default contain its base ID (the ID of the base plugin specifying the deriver), and its derivative ID (something unique within the collection of all plugins derived from the base plugin), creating a unique plugin ID. If a system wants to deviate from this and still maintains uniqueness, that is fine, but in this case you just ran into #2458769: Derivative plugin definitions contain base plugin IDs instead of derivative IDs, which is why I am closing this issue as a duplicate.

ekes’s picture

Is there any reason not to apply the patch though? The key will be unique for the list that needs to be created, thus showing all plugin derivatives correct id or not.

xano’s picture

Keys did not use to be documented as part of public APIs, which is why this was never done in the past. Now they are, so you're right about applying the patch. It won't fix this problem everywhere though, for instance when definitions are retrieved through DiscoveryInterface::getDefinition().

ekes’s picture

Status: Closed (duplicate) » Needs review

OK I'll add it to needs review: For this patch for this project, just to fix the lists here, at least while core gets its act together. It also makes it pretty obvious that they do return the same id, so it gives fair warning that there might be problems elsewhere ;)

Can you think of anywhere else in this project that it's making lists keyed on the getId(), where it could use the key, to ensure they're all available?

xano’s picture

There are 10 non-test usages of \Drupal\plugin\PluginDefinition\PluginDefinitionInterface::getId() of which 5 could potentially be converted to using the plugin IDs retrieved from the keys from DiscoveryInterface::getDefinitions()'s return value. The other usages work with individual definitions, and in those cases the ID can only be gotten from the definition itself.

I do want to urge you to chime in in that core issue. It's a real bug that breaks things, and we need some good insights to move it forward, because we can no longer break BC.

xano’s picture

joachim’s picture

Status: Needs review » Reviewed & tested by the community

The patch here fixes the problem.

joachim’s picture

I think there's a follow-on to fix -- PluginDefinitionInterface doesn't understand derivative IDs, and getID() returns the base ID.

  • joachim committed 726eb6ee on 8.x-2.x authored by ekes
    Issue #2767065 by ekes, joachim: Fixed plugins with derivers aren't...
joachim’s picture

Status: Reviewed & tested by the community » Fixed

In the meantime, I've committed this with a small tweak to show the full ID in the column.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.