Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Environment variables values should override cached values #35045

Open
michael-bouvy opened this issue Feb 1, 2022 · 4 comments
Open

Environment variables values should override cached values #35045

michael-bouvy opened this issue Feb 1, 2022 · 4 comments

Comments

@michael-bouvy
Copy link

Description (*)

Magento allows overriding configuration values using environment variables : https://devdocs.magento.com/guides/v2.4/config-guide/deployment/pipeline/example/environment-variables.html

When overriding a config value, for instance setting CONFIG__DEFAULT__WEB__SECURE__BASE_URL to override web/secure/base_url, the env variable value is loaded as expected and stored in cache.

However, Magento does not re-read environment variables values when already cached, making it impossible to define custom values for env variables at runtime, which may be very useful for CLI commands.

Expected behavior (*)

When getting a config by path, its value should systematically be checked in environment variables, before trying to get it from the cached config.

Exemple with config cache enabled:

export CONFIG__DEFAULT__WEB__SECURE__BASE_URL=http://localhost:8080

bin/magento cache:clean

# At this point, ScopeConfigInterface::getValue('web/secure/base_url') === 'http://localhost:8080', which works as expected

CONFIG__DEFAULT__WEB__SECURE__BASE_URL=http://localhost:8081 bin/magento my:command

# At this point, the "my:command" console command still reads the previous config value, the env variable override does not apply

Benefits

Being able to change config values at runtime without requiring to clear the cache.

Additional information

This is basically how Symfony and most frameworks behave when using environment variables.

@m2-assistant
Copy link

m2-assistant bot commented Feb 1, 2022

Hi @michael-bouvy. Thank you for your report.
To speed up processing of this issue, make sure that you provided the following information:

  • Summary of the issue
  • Information on your environment
  • Steps to reproduce
  • Expected and actual results

Make sure that the issue is reproducible on the vanilla Magento instance following Steps to reproduce. To deploy vanilla Magento instance on our environment, Add a comment to the issue:

@magento give me 2.4-develop instance - upcoming 2.4.x release

For more details, review the Magento Contributor Assistant documentation.

Add a comment to assign the issue: @magento I am working on this

To learn more about issue processing workflow, refer to the Code Contributions.


⚠️ According to the Magento Contribution requirements, all issues must go through the Community Contributions Triage process. Community Contributions Triage is a public meeting.

🕙 You can find the schedule on the Magento Community Calendar page.

📞 The triage of issues happens in the queue order. If you want to speed up the delivery of your contribution, join the Community Contributions Triage session to discuss the appropriate ticket.

✏️ Feel free to post questions/proposals/feedback related to the Community Contributions Triage process to the corresponding Slack Channel

@Usik2203
Copy link
Contributor

Usik2203 commented Feb 8, 2022

@magento give me 2.4-develop instance

@magento-deployment-service
Copy link

Hi @Usik2203. Thank you for your request. I'm working on Magento instance for you.

@magento-deployment-service
Copy link

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Feature Requests Backlog
  
Ready for Grooming
Development

No branches or pull requests

2 participants