Open bendeca opened 4 years ago
Yes, this is dangerous. I use a .env value for the url of the site in my system.yaml. Then I add my license key through the CP and this get's overwritten with the current local url. If I deploy that the site is broken. I've had that happen multiple times.
When I save the cache settings page it overwrites my static_caching_exclude causing big issues for contact form. This is when I use env vars to set the cache settings.
Probably related to the above so thats why I write it here.
stache_always_update: '{env:STACHE_ALWAYS_UPDATE}'
static_caching_enabled: '{env:STATIC_CACHING_ENABLED}'
stache_lock_enabled: true
stache_lock_wait_length: 30
static_caching_lock_hold_length: 0
static_caching_type: '{env:STATIC_CACHING_TYPE}'
static_caching_ignore_query_strings: '{env:STATIC_CACHING_IGNORE_QUERY_STRINGS}'
static_caching_file_path: public/static
static_caching_invalidation: all
static_caching_exclude:
- /contact-us
Setting a variable in the system.yaml config to e.g. '{env:APP_URL}' causes the value to be overwritten with the value of the current .env file. This only happened to me in the system.yaml config and only when editing the license key through
cp/licensing
.But looking at the code, I can see that it could happen with any yaml config file.
To Reproduce Steps to reproduce the behavior:
TEST=foo
php_max_memory_limit: '{env:TEST}'
cp/licensing
and save !!! this bug does not appear when editing the license key in the config menu > settings > systemphp_max_memory_limit: foo
Expected behavior variables handled by .env file should never be overwritten via the control panel.
Environment details (please complete the following information):
FIX The problem lies within statamic/core/Config/Settings.php
The logic is pretty much copied from statamic/core/Http/Controllers/SettingsController.php[58-63] This is also the function that gets called when editing the license key from the settings > system
Fixed content of statamic/core/Config/Settings.php: