Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Problem/Motivation
Should be usable via Drush.
Proposed resolution
The current patch introduces a Drush 9 class.
Remaining tasks
User interface changes
API changes
Comment | File | Size | Author |
---|---|---|---|
#18 | interdiff.txt | 1.29 KB | pfrenssen |
#18 | 2445463-18.patch | 6.51 KB | pfrenssen |
Comments
Comment #1
flocondetoileHello,
Attached a patch which add support for Drush. Adding this support permit me to find some little bugs for unsafe configuration changes. See #2703277: Unsafe configuration never listed and/or updated
Thanks for your review
Comment #2
nedjoLooks great, thanks!
I'm trying to find time for major refactoring in #2615146: Analyze diffs to do safe synchronization of customized configuration and #2678946: Repurpose core's config synchronization, so I'm slightly unsure of how that would affect these commands, but I'm comfortable meantime adding these.
Comment #3
james.williams CreditAttribution: james.williams at ComputerMinds commentedThe previous patch didn't apply well -- here's a fixed version that creates the drush file afresh.
Comment #4
nedjoDidn't get this applied before major refactoring in #2793027: Refactor to use Configuration Provider and #2678946: Repurpose core's config synchronization. Will now need to be reworked to use new approaches
Comment #5
james.williams CreditAttribution: james.williams at ComputerMinds commentedExciting stuff, thanks for doing that work! Is there any other related work likely to come in the next few days/weeks that is worth holding out for first? I wouldn't want to go through refactoring this twice within a short space of time.
Just to document it somewhere too whilst I'm here, since my last patch, I've also been thinking that it would be good to have an option to the drush command like
--module-dir
, to allow 'reverting' all modules within/below a certain directory (e.g. within an install profile's modules/custom directory, which is my use case), to replace what we used to do with 'drush fra'.Comment #6
nedjoI think the major refactoring is done.
Two relevant changes in the recent refactoring.
First, I've removed the code that was specific to a particular extension. Instead, all changes from all extensionns are merged all at once.
The main reason for this change is dependency handling. Often, particularly with features, a given module's configuration may depend on that provided by other modules, so updates are best done as a set.
Also, for directories other than
config/install
, changes in a particular module may trigger changes in other modules. For example, configuration provided by Module A may satisfy config dependencies of Module B'sconfig/optional
items, meaning, again, that updates are best done as a set.Second, this module can no longer be used for reverting in the sense we used the term in D7. Instead, all changes are merged into the active configuration, retaining any overrides that have been made.
The initial Drush work seems to be two commands, one to initialize the merged configuration storage and one to run imports. Because we're reusing core's config sync importing, the second should be very similar to what's already in
drush config-import
.Comment #7
james.williams CreditAttribution: james.williams at ComputerMinds commentedAh. Ok - thanks for the update. Unfortunately I was using config_sync for the very use case of 'reverting' individual modules, or groups of modules. I do understand that dependencies can be an issue with that kind of workflow, but we're working to keep on top of those to ensure our config declares its dependencies appropriately. At least in our workflow with config_sync before the refactor, dependencies were recognised & processed, so issues could be avoided if they were at least declared accurately enough. So I'll look at what options we have for our intended workflow - it's likely that our focus will shift to other projects since you have a clear intention for config_sync now, that looks great, but just doesn't match what we were trying to achieve.
Comment #8
nedjo@james.williams: I think it's worth at least exploring if/how config_sync could continue to meet your use case. I've just posted two issues to try to capture at least most of what would be needed:
I'm definitely open to doing this and at first glance it doesn't look prohibitively difficult. Could you look over the two issues and see if they capture what you'd need?
Comment #9
james.williams CreditAttribution: james.williams at ComputerMinds commented@nedjo thanks for your understanding. In reality, I'm waiting to see where #2388833: Pull reusable routines out of configuration import/export form builders (core) and #2388253: Pull reusable config handling into new service (config_devel) end up going, as it looks to me as those will direct any workflow I'm aiming to use. Nothing against your module(s) or the direction they're heading, they just don't quite fit and I'd rather stay closer to core + config_devel (since that's virtually core for most of us, I expect!) where possible.
So for now, rather than adjust to using config_provider/config_sync, which never quite fit our usage/intention correctly anyway, I've rolled my own drush command to cover the 'features revert' / 'revert all' style workflow that we used to use: http://github.com/computerminds/cm_config_tools - this also incorporates ideas taken from elsewhere like https://www.previousnext.com.au/blog/introducing-drush-cmi-tools and leverages common functionality in config_update too.
Sorry to not take this any further!
Comment #10
nedjo@james.williams: thanks for the update. Even if it doesn't end up meeting your own requirements, this conversation's been a useful spur to improvements here in config_sync, so it's all good.
Comment #11
james.williams CreditAttribution: james.williams at ComputerMinds commentedyay :-)
I'll certainly continue to keep an eye on developments in config_sync!
Comment #12
pfrenssenI started working on a new drush integration that will work with the new approach in Config Sync, and with Drush 9. This isn't ready yet. The listing of config is done, but the update command is only partly implemented. I need to look into how I can run a batch process to apply the config updates from the merged config storage.
Comment #13
pfrenssenI completed the Drush commands by getting inspiration from the core config import commands.
Comment #14
nedjoThis looks great!
For
'retain-overrides'
, inConfigSyncInitializerInterface
, the corresponding parameter is named$retain_active_overrides
and the default value is TRUE. It also defaults to TRUE in the UI:We should be consistent with the naming and default value. Since we're in alpha it's fine to change the interface.
Let's use 'retain-overrides' in Drush and change
retain_active_overrides
toretain_overrides
in the interface and elsewhere in the code base. It's shorter to enter at the Drush command line.For the default value, there are probably two main use cases for Configuration Synchronizer. The first is to safely merge configuration changes from extensions into the active configuration. In this use case, the desired value is
TRUE
. The second is to revert the site's configuration to the current state of extension-provided versions. In this use case, the desired value isFALSE
.Since I wrote the module primarily for the first use case, I put it as the default. It may turn out use case 2 is equally or more used, but it's probably too early to tell. For now I suggest we switch the default to TRUE in the drush command.
Comment #15
nedjoComment #16
pfrenssenVery good suggestion, we should default to retaining the overrides. We have to flip the polarity of the option though, since it is a boolean option it is typical in POSIX to not assign a value to it, but to just include / omit the option. I think the reason for it is because it can be confusing to remember the value to turn it off: it can be "no", or "0" or "FALSE", ...
So instead of something like this:
It would probably be better to do the inverse, something like this:
What do you think?
Comment #17
nedjoAgreed, that sounds like the way to go.
Comment #18
pfrenssenFlipped the polarity of the option.
Comment #19
nedjoNice, thanks! This will fill a major gap in the module. Unless there are other pending changes, once this is committed, we should put out a new alpha release.
Comment #21
pfrenssenThanks! I've committed the patch and had a look through the open issues but there is nothing in RTBC or needs review any more, so this is indeed a good moment for rolling a new release. I'll take care of it.
Comment #22
nedjoThanks! I've added a note about using Drush to the project page. Please feel free to refine that, and also to add your company to the "supporting organizations" for the project.