Problem/Motivation
When we have a config override in settings.php that overrides a fake key stored in the database like this:
$config['cocoon_media.settings']['cocoon_media']['api_key'] = 'xxxxxxxxxxxxxxxxxxx';
We get an error when trying to add cocoon media (/media/add/cocoon_media_add).
Steps to reproduce
Use the admin interface to set a dummy cocoon media api key (/admin/config/media/cocoon_media_settings).
settings.php
$config['cocoon_media.settings']['cocoon_media']['api_key'] = 'the-correct-key';
Now try to add cocoon media (/media/add/cocoon_media_add). This should fail. Then override this dummy key with a config override in settings.php. Now try again to add cocoon media. This still fails.
Proposed resolution
The CMMAddMediaForm class extends ConfigFormBase, which uses editable config that cannot be overriden with config in settings.php. There are no changes done to the configuration in this class, so it has no need for editable config. Let the class extend FormBase, and inject the ConfigFactory service to get immutable config.
Remaining tasks
See patch, it needs review.
| Comment | File | Size | Author |
|---|---|---|---|
| #9 | interdiff_5-9.txt | 2.22 KB | thomasdegraaff |
| #9 | cocoon_media-fixes-override-config-issue-14828736-9.patch | 2.38 KB | thomasdegraaff |
| #5 | interdiff_2-5.txt | 494 bytes | thomasdegraaff |
| #5 | cocoon_media-override_config-5.patch | 932 bytes | thomasdegraaff |
| #2 | cocoon_media-override_config-2.patch | 989 bytes | thomasdegraaff |
Issue fork cocoon_media-3324754
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
thomasdegraaff commentedComment #3
thomasdegraaff commentedComment #5
thomasdegraaff commentedRemoves testing code in patch #2.
Comment #6
himanshu_jhaloya commentedComment #7
himanshu_jhaloya commentedComment #8
thomasdegraaff commentedComment #9
thomasdegraaff commentedThis patch replaces previous fix #5 that circumvents the actual problem with a real fix of the problem.
Comment #10
scuba_flyNice catch!
I've reviewed and tested your code.
The only issue is that the "test api" button does not use the settings from settings.php.
Now I don't know if that is a good or a bad thing.
I'll add this in the module, and add a description below the button that it uses the filled in API key.
Comment #12
scuba_fly