Problem/Motivation
Using a fully preconfigured settings.php with a config_sync_directory setting and a profile with a config/sync directory is broken.
Steps to reproduce
This is actually hard to reproduce at the moment due to the following bug https://www.drupal.org/project/drupal/issues/3247553
1. Before installing configure a settings.php with hash_salt, databases and config_sync_directory already set up.
2. During installation select a profile with a config/sync directory
Kaboom - you get an error.
Proposed resolution
To be decided... the problem is the user has expressed two conflicting intents for the location of the config/sync directory.
Option one
If $settings['config_sync_directory'] directory is empty copy the profile's config/sync directory there and continue with the install. If the directory is not empty then display en error to the user.
Option two
Trigger an error that's display on the installer requirements page that explains that choosing a profile that installs from configuration and having a configuration sync already defined in settings.php is an error. The error should list the following ways to resolve the error:
- edit settings.php and set the setting to the profile's config/sync directory
- remove the setting from settings.php
- choose another profile
Remaining tasks
Decide on fix.
User interface changes
API changes
Data model changes
Release notes snippet
| Comment | File | Size | Author |
|---|---|---|---|
| #11 | copy_profile_config_before_install_if_config_dir_defined-3247561-11.patch | 1.76 KB | realityloop |
Issue fork drupal-3247561
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #2
realityloop commentedComment #3
realityloop commentedComment #4
realityloop commentedComment #5
realityloop commentedComment #6
realityloop commentedComment #7
realityloop commentedAdditionally it's currently impossible to install a config only profile if you have already set the config_sync_directory before installation.
This is pre-defined in ddev for instance.
The proposal in this issue would resolve that.
Comment #8
realityloop commentedComment #9
realityloop commentedComment #10
realityloop commentedI'm sure this isn't the best way to do it, but it does resolve this issue.
Comment #11
realityloop commentedFixed a typo in patch (comma that should have been period in comment)
Comment #12
alexpott@realityloop we cannot make this change like this. This satisfies the way you want it to work but not others. We cannot change the default behaviour here.
I think we need to go back to first principles and ask whether an install profile is really what you need here.
Comment #13
alexpottI think given that what you want to be able to provide is a starting set of configuration and then no longer care about it we should not use install profiles at all. If install profiles are used you will aways have two full sets of config lying around being confusing for no reason.
Comment #14
alexpottAlso is what is happening so wrong? I don't think so. I think you might even be able to use install profiles / composer to make everything behave the way you want. But the install profile would not be drupal.org. The install profile could live as part of a composer project and therefore is only instantiated when someone runs composer create-project.
Here's how I think it would work:
Your project would create the install profile with a config/sync directory... you could even encourage people to name this something to do with what they are building. And it would just work™
Comment #15
realityloop commented@alexpott
#12: I didn''t believe I had changed the default behaviour? My patch only does something different if
$settings['config_sync_directory']is already defined in settings.php before you install the site.#13: With the active sync directory configuration being written to settings.php on install, I personally struggle to see how this is any more confusing than having the code from an upstream contrib profile changing in your local project as you manage the site and export config.
With a workflow where you are using composer to build your codebase and git ignoring all contrib dependencies the existing behavior could either:
A cardinal rule in our development has for the longest time has been no code changes in core or contrib that aren't enacted via a patch in the issue queue at drupal.org and applied at build time. This has always been to guard against undocumented changes.
When using a profile containing a config/sync directory to package settings, the current behavior makes undocumented changes to the content of that contrib dependency in your project. To me at least this seems very undesirable.
#14: Yes, it could be done this way, but drupal.org has no way to host these afaik? Therefore we get no usage tracking of active installs.
Comment #16
alexpottThis will break config install from profiles on envs like ddev which try to set config_sync_directory incorrectly.
Don't put the profile in profiles/contrib put it in profiles/ and encourage people to make it theirs.
Comment #17
realityloop commented@alexpott I'm not sure how you believe this would break ddev install?
I tested it, and here is a video showing that after applying your patch in https://www.drupal.org/project/drupal/issues/3247553 installation of a config only profile will still fail anywhere that
$settings['config_sync_directory']is already defined unless my patch here is also applied.I'd believe that if this has already been defined it means that the developer want's it to be stored in the defined directory, and would not expect it's definition to cause an install failure.
https://youtu.be/fiQwSV5CtkQ
Comment #18
alexpott@realityloop a good question posed by this issue is exactly what should happen if you install a profile with a config/sync directory and the sync directory is already set in settings.php. As this issue makes clear ATM this is broken. I think we need to add an error to the installer if the config sync directories mismatch as the user has indicated two very different wishes - they're using a profile which has a config/sync directory and they set config_sync_directory to something else in settings.php.
As I've pointed out already in this issue I think the solution to the issue of using composer to grab a set of config and install from that could have a solution that does not involve install profiles and I think that we should do that to provide the feature that's requested in the issue summary.
Comment #19
realityloop commented@alexpott I’ve already refactored Foundry to package the config with the composer project.
But have left the issue open because I agree the current handling is broken.
One option would be to confirm if the configured sync directory is empty, if not copy the configured as I did with my patch.. if it isn’t show error as you suggested.
Comment #20
alexpottI'd love to see a write of this approach somewhere. v. interested to see how we can streamline this.
I've re-titled the issue to be a bit more buggy and rewritten the issue summary to focus on the bug.
I think we need to go for option 2 because: