use config only if enabled otherwise just deployment-config #158
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
I noticed some weird behavior with the config. When you try to override in the backend by enabling
sentry/environment/enabled
and then disable it, sentry is just always disabled, like described here: #128 so I fixed it by just checking if it is enabled or not and if it is not it just uses the deployment-config. Also for the additional settings, because thelog_level
was overridden by the setting, because it is a source model it always has a value when saved. Now the overridden values are only used whensentry/environment/enabled
flag is true.I also saw this PR #144 which is great, but also adds another setting and in my opinion the enabled setting can just be used instead of an extra override setting. So basically this PR also does this, and indeed the try catches are not needed.
I deliberately used a simple if/else to make it more readable, it could be fancier, but I think a readable solution is better here.
Result
Deployment-config is always leading for enabling the service. But when backend config is used settings can be overridden only if
sentry/environment/enabled
is true, in that case backend config is used over deployment-config. When a setting like DSN is not filled in de backend config, it just falls back to the deployment configChecklist
composer run codestyle
composer run phpstan