Problem/Motivation
For use cases including producing Drupal distributions, certain processing is needed to change configuration on export.
Currently we make two such changes in FeaturesManager::addPackageFiles():
// The UUID is site-specfic, so don't export it.
if ($entity_type_id = $this->configManager->getEntityTypeIdByName($name)) {
unset($config['data']['uuid']);
}
// User roles include all permissions currently assigned to them. To
// avoid extraneous additions, reset permissions.
if ($config['type'] == 'user_role') {
$config['data']['permissions'] = [];
}
An additional case is #2599268: Enable filtering of recipients on export of contact forms.
However:
- The current approach is not extensible; changes require new hard-coding.
- The current approach isn't configurable; all processing is always applied.
Processing could be implemented through new configurable assignment plugins, since assignment plugins can access and alter the full configuration array, though such a plugin wouldn't actually do any assigning of configuration to packages, so is stretching the use case of assignment plugins. Also, a processor plugin doesn't need to be weighted in relation to assigners, since the processing won't affect assignments.
We already have one assignment plugin that fits these criteria for a processor plugin: 'optional'. It doesn't create any packages or assign any configuration; it just processes the configuration collection.
So we could add a new plugin type, 'processor', and convert the 'optional' assignment plugin into a processor plugin, but this would add considerable complexity and create two different plugin types that are structurally identical. Therefore, probably best to keep this as a new assignment plugin.
Proposed resolution
Convert the current hard-coded processing in FeaturesManager::addPackageFiles() into a new configurable assignment plugin.
Remaining tasks
User interface changes
API changes
Data model changes
| Comment | File | Size | Author |
|---|---|---|---|
| #5 | features-alter-2599278-5.patch | 13.38 KB | nedjo |
Comments
Comment #2
nedjoComment #3
nedjoAttached patch adds a new alter assignment plugin and moves the existing processing for _
core,uuid, and user permissions to that plugin. Includes:To test:
_core,uuid,permissions._core,uuid,permissions.Comment #4
nedjoFixing up tests.
Comment #5
nedjoPrevious patch empty. This should be the right one.
Comment #8
nedjoThe test failure is from #2833258: Test failure from core change, so all tests introduced in this patch are passing.
Comment #9
jsst commentedI've installed this patch, ran update:execute and exported some features with varying combinations of the three alteration types. Works like a charm! Patch looks good from a technical and coding style perspective as well.
Couldn't verify the passing tests though.
Comment #11
nedjo@jsst: thanks for testing and reporting back.
Applied.
Comment #13
joshua.boltz commentedIn what scenarios would it be dangerous to uncheck the "Strip out user permissions" option?
Comment #14
nedjo@joshua.boltz
Since this issue was a feature request and is now closed, it works best if you can open a new issue for your support request. Thanks!