Problem

\Drupal\Component\Plugin\Discovery\DerivativeDiscoveryDecorator uses a colon to separator base and derivative plugin IDs for plugin derivatives. While this is readable, it does not allow using the plugin ID in filenames: \Drupal\Core\Config\Config::validateName() will throw an exception, for instance.

Use case

I have a plugin type Foo that has a derivative for every instance of field type Bar. The derivative IDs consist of the base plugin ID, a colon, and the field instance ID.
For every derivative, entity type Baz of which the bundle == Foo plugin ID gets a field instance of field type Qux. As Qux is attached to an entity type with a bundle name that contains a colon (the derivative plugin ID), Qux's primary identifier will also contain that colon.
When saving Qux, which is a field instance config entity, its identifier (which contains the colon), will be used as the name of the file by ConfigStorageController, which causes an exception in \Drupal\Core\Config\Config::validateName().

Proposed solution

Use another character as the separator. It will have to be allowed by file systems, but cannot be be part of the set of allowed characters for machine names. Based on the Wikipedia Comparison of file systems article, I would like to propose we replace the colon with the space. According to the article, the only systems that do not support it are CP/M and ADFS, both of which seem so outdated we probably do not want to support them.

I know this can be fixed by simply overriding (Container)DerivativeDiscoveryDecorator, but it seemed to me that a simple problem like this should receive a fix in core to make it easier for other developers.

Comments

tim.plunkett’s picture

Status: Active » Closed (duplicate)

Duplicate of #2035345: Reconsider whether to use ':' as separator for derivative plugins, that has more people following it, lets just do it there.