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

[11.x] Fixes config:cache command detects incorrect custom environment file #52793

Draft
wants to merge 1 commit into
base: 11.x
Choose a base branch
from

Conversation

fuga
Copy link

@fuga fuga commented Sep 14, 2024

The artisan config:cache command genarate incorrect configuration values under certain conditions.

Under the following conditions, the values set in the .env file are expected to be used, but the artisan config:cache command outputs the settings derived from the .env.[APP_ENV] file to the cache file.

  1. there is an .env.[APP_ENV] file with the same extension as the APP_ENV value set in the .env file
  2. no APP_ENV environment variable is provided externally.

The reason for this is that the getFreshConfiguration() method in the artisan config:cache command, the second application bootstrap process is executed, but the LoadEnvironmentVariables bootstrap process does not take into account multiple executions and takes the value of APP_ENV from the dotenv generated in the first run.

Purely externally provided variables can only be retrieved before loading dotenv.
In this fix, on the second and subsequent bootstrap processes reuse the values retrieved the first time.

…les.

Purely externally provided variables can only be retrieved
before Dotenv is loaded, so the second and subsequent
bootstrap processes reuse the values retrieved the first time.
@crynobone crynobone changed the title [Fix] The config cache command detects incorrect custom environment file. [11.x] Fixes config cache command detects incorrect custom environment file. Sep 16, 2024
@crynobone crynobone changed the title [11.x] Fixes config cache command detects incorrect custom environment file. [11.x] Fixes config:cache command detects incorrect custom environment file Sep 16, 2024
@taylorotwell
Copy link
Member

taylorotwell commented Sep 16, 2024

Please provide better recreation instructions. Please mark as ready for review when the requested changes have been made.

@taylorotwell taylorotwell marked this pull request as draft September 16, 2024 14:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants