fix: Make sure env-type settings are populated before start, don't override .ddev/.gitignore file, for #7236#7286
Conversation
|
Download the artifacts for this pull request:
See Testing a PR. |
stasadev
left a comment
There was a problem hiding this comment.
Thank you, I tested the Craft CMS quickstart using this PR, and now it updates .ddev/.env.web as expected.
|
Open to suggestions about whether we should get this into this release. I don't foresee problems with doing the settings early, but perhaps I'm being naive. I didn't see any of the settings creators that tried to use a running container either. |
|
To be safe, it can be merged early in the next release. The workaround is to leave I don't see any issues with this fix, but we can test it for a longer time in DDEV HEAD. |
|
Rebased |
642dd08 to
a2dc75f
Compare
.ddev/.gitignore file, for #7236
|
The first post is updated with We may want to think about how to properly gitignore This is probably a task for: |
| if _, err = app.CreateSettingsFile(); err != nil { | ||
| return fmt.Errorf("failed to write settings file %s: %v", app.SiteDdevSettingsFile, err) | ||
| } | ||
|
|
There was a problem hiding this comment.
I think we should have app.CreateSettingsFile() in both places, on pre-start and post-start.
I suggest to bring back this removed condition.
This code runs only when site is running:
Lines 565 to 582 in 7b0cb14
There was a problem hiding this comment.
IMO it's pretty safe to do that, but here it was inside mutagenEnabled right?
There was a problem hiding this comment.
I added it back where it was before (but that was late in Start, not in mutagen section)
| if path.Dir(app.SiteSettingsPath) != app.AppRoot { | ||
| // Don't override the existing .ddev/.gitignore as well | ||
| // TODO: we may want to append to .ddev/.gitignore if needed. | ||
| if path.Dir(app.SiteSettingsPath) != app.AppRoot && path.Dir(app.SiteSettingsPath) != app.GetConfigPath("") && app.SiteDdevSettingsFile != "" { |
There was a problem hiding this comment.
Fascinating. I'll take a bit of a look at this in the light of its history. The reason this was like this was that the drupal sites/default had to have its own gitignore IIRC.
There was a problem hiding this comment.
This is great; now I understand the whole history and the stumble here.
a2dc75f to
cec8720
Compare
|
I made minor changes and re-added the previous near-post-start settings update. I don't understand exactly why it would be needed, but don't see it doing any harm. |
stasadev
left a comment
There was a problem hiding this comment.
Thank you!
Adding code without deleting it seems safer to me.
Tested it again, the .ddev/.env.web file is updated on ddev start (I edited it during the start, and it was updated again)
And .ddev/.gitignore is not broken.
The Issue
.ddev/.env.webfor Craft CMS DDEV settings, fixes #7233 #7236In #7236 (comment) @stasadev pointed out that now that we're using .ddev/.env* for settings (instead of using php application-defined settings load techniques) the settings/env values may be loaded too late (after containers are up) in some situations.
Before #7236 I believe that all explicit use of settings, including project types that used project-level .env (loaded by PHP dotenv for example) were application-loaded, which meant that it didn't matter that we wrote the .env late (post-start). But now with #7236 we're using DDEV's .ddev/.env.* so those only get loaded during
docker-compose up, and need to be written beforedocker-compose up.The CraftCMS config overrides
.ddev/.gitignorecompletely (which is wrong), and our logic for settings files creates.gitignorefile in the directory of the settings file. Since CraftCMS uses.ddev/.env.web, its parent is.ddev, so it used.ddev/.gitignore.How This PR Solves The Issue
Move the call to app.CreateSettingsFile() in the start sequence to before the
docker-compose upDon't override
.ddev/.gitignorefor CraftCMS.Manual Testing Instructions
Mostly automated tests should tell us about this;
A good check of Craft CMS in light of #7236 (comment) is a good idea
Automated Testing Overview
No changes.
Release/Deployment Notes