[11.x] Fixes config:cache
command detects incorrect custom environment file
#52793
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.
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.
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.