The standard install profile provides system.cron.yml config file, with non-default cron settings, but this file is not used by the install system.
What are the steps required to reproduce the bug?
Install Drupal 8 selecting the standard install profile.
What behavior were you expecting?
Drupal 8 is installed and cron is configured as per the settings in core/profiles/standard/config/system.cron.yml.
What happened instead?
Drupal 8 was installed but cron used the configuration from core/modules/system/config/system.cron.yml, ignoring the configuration provided by the installation profile.
Related issues
#1934700: Automated cron runs should only be enabled by default for Standard profile
#606840: Enable internal page cache by default
Comment | File | Size | Author |
---|---|---|---|
#55 | interdiff.txt | 3.06 KB | jessebeach |
#55 | drupal-config-overwrite-1986090-55.patch | 5.4 KB | jessebeach |
#52 | interdiff.txt | 1021 bytes | markpavlitski |
#52 | drupal-config-overwrite-1986090-51.patch | 5.57 KB | markpavlitski |
#41 | drupal-config-overwrite-1986090-41.patch | 5.58 KB | jessebeach |
Comments
Comment #1
markpavlitski CreditAttribution: markpavlitski commentedThis patch addresses the issue by setting the configuration in standard_install().
Comment #2
Dave ReidI don't think this is the correct fix, because otherwise what is the point of shipping default config files in the profile?
Marked #1958770: Cron default should never be "Never" as a duplicate of this issue since this had a nicer issue summary already.
Comment #3
Dave ReidI think the issue must be that system ships with a default system.cron.yml file, and so does the standard profile. We have two conflicting default configurations and it doesn't work. This is a major problem for install profiles.
Comment #4
Dave ReidNeeds work and tests for a proper fix.
Comment #6
swentel CreditAttribution: swentel commentedTagging - afaics, this will need changes deep down in config
Comment #7
markpavlitski CreditAttribution: markpavlitski commentedCurrently modules can only provide new configurations; any files in the /config directory which match an existing configuration are skipped during installation.
This patch allows modules (including install profiles) to make changes to existing configurations during their installation process.
This will mean the fix in #1934700: Automated cron runs should only be enabled by default for Standard profile will actually take effect.
Comment #9
markpavlitski CreditAttribution: markpavlitski commentedThe patch in #7 caused issues when enabling and disabling modules.
This patch only allows the install profile to overwrite existing configurations. Since it is always the last module installed, it should allow profile writers to amend any core configuration as necessary.
Any config files in the install profile are merged in to the existing configuration, so only changes are necessary in the yml file. See also #1934758: Allow installation profiles to partially override module default configuration settings.
Tests for the new functionality are included.
Comment #10
tim.plunkettAll of these functions are about to become methods in #1890784: Refactor configuration import and sync functions, just a heads up.
Comment #11
markpavlitski CreditAttribution: markpavlitski commented@tim.plunkett Thanks for the heads up. Will reroll once #1890784: Refactor configuration import and sync functions is committed.
Comment #12
markpavlitski CreditAttribution: markpavlitski commentedFirst attempt at re-roll using the new config import system.
Comment #13
kerasai CreditAttribution: kerasai commented#12: drupal-overwrite-config-1986090-12.patch queued for re-testing.
Comment #14
pplantinga CreditAttribution: pplantinga commentedI can confirm that this issue exists and that this patch fixes it.
Comment #15
catchThe only time we install install profiles is via the installer, couldn't this logic happen there?
Comment #16
markpavlitski CreditAttribution: markpavlitski commented@catch I suppose we could define
$install_profile
as a global variable and set it in the installer, but that seems messier if anything?Edit: We could pass in additional parameter instead, and leave it up to the caller to decide if it's safe/sensible to overwrite other modules' configs.
Comment #17
markpavlitski CreditAttribution: markpavlitski commentedAdjusted the patch as per catch's suggestions, moving the logic into the installer.
Comment #18
Anonymous (not verified) CreditAttribution: Anonymous commentedi don't like this patch.
i don't think we should introduce the 'merge' concept. either overwrite the whole file, or use profile install hook code to get the config object and update it in code.
this looks to me like yet another complication of what should be a simple, dumb process. IMO, the code we have is already waaaay over-engineered for the job.
having said that, i'm not going to block this, so feel free to ignore this comment.
Comment #19
markpavlitski CreditAttribution: markpavlitski commented@beejeebus I think the main benefit of this method is it allows install profile devs to provide default configs in the same way as everyone else, by just bundling the YAML files, rather than changing config in code.
Overwriting the whole config could work, but would mean a bit more effort tracking changes in any other modules provided by the install profile. I.e. if ctools is bundled with an install profile and decides to add an extra config line, the install profile would need to be updated to include that config line too otherwise it could break ctools.
See also #1934700: Automated cron runs should only be enabled by default for Standard profile. The fix committed there doesn't actually do anything, but it had been assumed that this merge behaviour was already present.
Comment #20
catchIt's not really the same as everyone else though. Modules don't get to provide overrides of configuration provided by other modules.
Comment #21
markpavlitski CreditAttribution: markpavlitski commentedTrue. I just meant that it would be useful for install profiles to be able to use the same configuration mechanism (YAML files) to deliver site config, rather than having to overwrite every config option in code.
Note that this issue started as a bug fix, removing a YAML file in the standard installer and adding the config change in code (in the way that beejeebus suggested in #18), and has morphed into installer config merging.
Perhaps we should just go back to the original fix instead?
Comment #22
Anonymous (not verified) CreditAttribution: Anonymous commentedre #21, i discussed this with alexpott in IRC.
we both support a simple special case for profiles, where profiles can ship files that overwrite configuration from other modules. please continue with a patch along those lines.
Comment #23
markpavlitski CreditAttribution: markpavlitski commented@beejeebus Thanks for the feedback, I'm working on this approach now.
Comment #24
markpavlitski CreditAttribution: markpavlitski commentedNew patch which allows install profiles to ship config files which can replace config from other modules, as per #22.
Includes test coverage.
No interdiff as the approach is quite different.
Comment #25
markpavlitski CreditAttribution: markpavlitski commentedComment #25.0
markpavlitski CreditAttribution: markpavlitski commentedAdding related issues.
Comment #25.1
swentel CreditAttribution: swentel commentedUpdated issue summary.
Comment #26
markpavlitski CreditAttribution: markpavlitski commented24: drupal-overwrite-config-1986090-24.patch queued for re-testing.
Comment #27
KartagisI have tested and hereby confirm that it works.
Comment #28
markpavlitski CreditAttribution: markpavlitski commented24: drupal-overwrite-config-1986090-24.patch queued for re-testing.
Comment #30
swentel CreditAttribution: swentel commentedComment #31
markpavlitski CreditAttribution: markpavlitski commented@swentel, it would be great to get eyes on this issue. What can I do to help get this through?
Re-rolled patch attached.
Comment #32
markpavlitski CreditAttribution: markpavlitski commentedComment #33
Gábor Hojtsy#2140511: Configuration file name collisions silently ignored for default configuration is somewhat related, although the problem there is module/module config collisions in which case the new file will not be copied and should not override the existing file.
Comment #34
Gábor HojtsyCrosspost.
Comment #35
sunI also discovered this while debugging #2190723: Add a KeyValueStore\FileStorage to replace e.g. ConfigStorage, because the changes to
InstallStorage
in that issue are causing the profile config file to be discovered and properly installed.The proposed fix here is wrong though —
ExtensionInstallStorage::getAllFolders()
simply does not add the installation profile to the folders to scan.InstallStorage::getComponentNames()
overwrites config names of former directories with config names of later directories.In other words, the initial/resulting list of
$config_to_install
inConfigInstaller::installDefaultConfig()
is supposed to contain the full list of configuration file names with proper overrides already, including overrides by the installation profile. A separate scan/list + manual replacement for the profile config only is unnecessary/wrong.Comment #36
markpavlitski CreditAttribution: markpavlitski commented@sun I think this was the approach taken in the original patch, up to #17.
The issue is that overrides are only allowable for the install profile, so there has to be a special case somewhere (from #22).
This seemed like the cleanest place to add it, but thoughts welcome.
Comment #37
markpavlitski CreditAttribution: markpavlitski commentedComment #38
markpavlitski CreditAttribution: markpavlitski commentedLooking at this further, this is exactly what the patch is doing.
$config_to_install = $source_storage->listAll($name . '.');
ExtensionInstallStorage::listAll()
usesExtensionInstallStorage::getAllFolders()
to work out the list of config entries, and the extra code added here is what's adding the proper overrides.We have to check and only apply the matching overrides, because this is called for every module during install, and we only want to override the config which is about to be enabled.
@sun can you please clarify if I'm missing something?
Comment #39
markpavlitski CreditAttribution: markpavlitski commentedCorrecting status
Comment #40
Berdir31: drupal-overwrite-config-1986090-31.patch queued for re-testing.
Comment #41
jessebeach CreditAttribution: jessebeach commentedJust correcting a small spelling error in a comment.
Comment #42
jessebeach CreditAttribution: jessebeach commentedThe initial list of configurations to install is misleading.
InstallStorage::listAll()
just returns an array of keys. So it's impossible to know what should be overridden at this point. With markpavlitski's patch in #31, it will contain the right filenames (even though their overridden status is not known because the path information is not listed in$config_to_install
).InstallStorage::listAll()
invokesExtensionInstallStorage::getAllFolders()
, which contains the profile path override.The real magic happens in
ConfigInstaller::installDefaultConfig()
with this code:Here,
FileStorage::read()
gets the data for the config file with$data = file_get_contents($this->getFilePath($name));
, butgetFilePath()
is overridden.<code>FileStorage::read()
is really invokingInstallStorage::getFilePath()
, which then callsExtensionInstallStorage::getAllFolders()
, where we apply the profile override.So sun's recommendation in #35 is essentially correct and markpavlitski's assertion in #38 that this is what the patch is doing is also correct.
I've reviewed this code up down and sideways and the tests as well. I'd set it to RTBC, but I want to give sun the chance to respond. Hopefully everything is in order and we can get this in to allow further work on some critical beta blocking issues.
Awesome work folks!
Comment #43
BerdirI didn't look in depth, so I can't RTBC/confirm that the implementation is correct either, but can verify that this is working as expected on a custom install profile. Removing Needs Tests tag.
Comment #44
alexpottReviewed and tested the code and the solution does indeed look nice and clean. I can not tally @sun's comments in #35 with the patches in #31 and #41 and believe that #35 must have been a review of the earlier approach because afaics the current approach is exactly what @sun is recommending :)
Comment #45
jessebeach CreditAttribution: jessebeach commentedAssigning to webchick to get this on her radar for the next commit spree.
Comment #46
sunYes, the new code is what I meant. Some concerns on reviewing the latest patch though:
Isn't that a completely different issue/bug than the scope of this issue?
Why would we allow any module to override settings (as opposed to config entities) of any other module?
Shouldn't that ability be limited to installation profiles only?
Enabling the poormanscron feature in the Testing profile by default presents a significant change to the default testing environment for all web tests.
Instead of enabling autorun, can we change the requirements warning/error thresholds instead, please?
Comment #47
sunAlso, to continue on #46.1)
At the point in time at which
config_override_test.module
is installed,system.module
is installed already, so the active configuration contains thesystem.cron
file imported fromsystem.module
's default configuration already.As a consequence, config_override_test's attempt to provide a system.cron configuration cannot work out, because that config object exists already.
If the
ConfigInstaller
allows modules to blatantly overwrite your existing, custom configuration (in your active config directory), then that would be a completely different, highly critical security issue, which would have to be addressed in a separate issue.But I hope that is not the case. In any case, that part of the added test coverage here does not make sense.
Comment #48
alexpott@sun
1. Agreed and this is exactly what this is testing :). This patch is adding system.cron.yml to ensure that modules cannot override other modules configuration and it is testing this. Although this test will be moot once #2140511: Configuration file name collisions silently ignored for default configuration so I agree this probably should be removed.
2. Yep makes sense
Comment #49
jessebeach CreditAttribution: jessebeach commentedNoted, I'm fixing up #2140511: Configuration file name collisions silently ignored for default configuration this morning.
Comment #50
markpavlitski CreditAttribution: markpavlitski commentedI will re-roll the patch to change one of the other settings instead. Is it worth leaving the test in for now and removing as a follow-up if/when #2140511: Configuration file name collisions silently ignored for default configuration is removed? Or shall I remove it now?
Comment #51
jessebeach CreditAttribution: jessebeach commentedI would rather remove the test later (later probably being in a couple days). I'll be responsible for making sure it gets removed.
Comment #52
markpavlitski CreditAttribution: markpavlitski commentedThis patch sets a higher cron warning period instead. The test is still present.
Comment #53
sunOK, thanks! @alexpott, please go ahead and commit (doesn't look like you authored any of it) :-)
Comment #54
alexpottChange the patch one final review and realised that we should change the test to ensure more clarity about what is going on....
Lets call this $expected_profile_data since overriden (a) means something very specific to the config system (b) is mispelt :)
This is not necessary as the configuration override system is not relevant to this change.
Lets not use the word override here since this is not about the configuration override system. overwrite is okay... but in fact configuration is never actually overwritten. This change is all where default configuration comes from. It enables installation profiles to provide different default configuration on behalf of modules.
Comment #55
jessebeach CreditAttribution: jessebeach commentedHere are the changes outlined in #54.
Comment #56
sunComment #57
alexpottCommitted 53ef54c and pushed to 8.x. Thanks!