Problem/Motivation
1. AddressProvider plugin config is unnecessarily being serialized and un-serialized
It is difficult to override config for an AddressProvider plugin when the configuration is serialized.
Instead of:
$config['address_autocomplete.settings']['google_maps']['api_key'] = 'foo';
One must specify a serialized array:
$config['address_autocomplete.settings']['google_maps'] = 'a:2:{s:9:"plugin_id";s:11:"google_maps";s:7:"api_key";s:3:"foo";}';
Additionally, it does not appear that the serialization and un-serialization of the plugin config is actually necessary.
2. Immutable (potentially overridden) config values are displayed in config admin screens for edit
This can lead to confusion and is not standard practice in module config forms.
3. We appear to be lacking a configuration schema file for our module settings
Proposed resolution
- Add a configuration schema file
- Write an update hook to un-serialize and re-save the AddressProvider plugin configuration and remove the serialization and un-serialization steps when saving and loading config.
- Display mutable/editable config values in module configuration forms
Remaining tasks
User interface changes
DX: Easier / standard configuration overrides, easier to read config in config files.
UX: Less confusion in settings forms when configuration overrides are present.
API changes
Data model changes
| Comment | File | Size | Author |
|---|---|---|---|
| #4 | address_autocomplete-config-issues-3311019-4.patch | 6.19 KB | vaish |
| #2 | address_autocomplete-config-issues-3311019-2.patch | 4.59 KB | chrisolof |
Issue fork address_autocomplete-3311019
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
Comment #2
chrisolofThe attached patch fixes the configuration issues outlined above. Needs review and testing.
Comment #3
routinet commentedPatch at #2 did not work for me. After applying patch, with no override configured, I receive a serialized value for, e.g., 'google_maps'. With an override configured for api_key, I receive an array with 'api_key' as the only key.
Before override:
After override:
Comment #4
vaish commentedHere is a new version of the patch from #2. Tested both on Drupal 9.5 and Drupal 10.1. Main difference is a fix for an error
which occurs when attempting to edit provider settings for the very first time while they are still undefined. In addition to that, I converted variable into a constant and injected Guzzle Http client instead of instantiating it in the constructor.
Note: If you want to use this patch on Drupal 10, you also need to apply #3349849-12: Drupal 10 compatibility.
Comment #7
vaish commented