drush-ops / drush

Drush is a command-line shell and scripting interface for Drupal, a veritable Swiss Army knife designed to make life easier for those who spend their working hours hacking away at the command prompt.
https://www.drush.org
2.34k stars 1.08k forks source link

Dependencies are not skipped when config-export --skip-modules is used #1820

Closed gaelg closed 7 years ago

gaelg commented 8 years ago

If one skips some module (let's say Devel) when exporting configuration, the dependent config entities won't be skipped (you'll still get a devel.settings.yml file in the export). And this can break the import in another instance of the same site, because of dependency validation. The error will come from https://api.drupal.org/api/drupal/core!lib!Drupal!Core!EventSubscriber!ConfigImportSubscriber.php/function/ConfigImportSubscriber%3A%3AvalidateDependencies/8

nevergone commented 8 years ago

Confirmed. :(

nevergone commented 8 years ago

drush config-import also affected.

thenetexperts commented 8 years ago

still a problem in 8.0.2, for now one could add the dependent config files to a .gitignore until solved

nevergone commented 8 years ago

This issue is independent from git.

thenetexperts commented 8 years ago

yes of course. I was merely pointing out that, in the meantime, you could add the created dependent configuration .yml files (for example devel.settings.yml) to a .gitignore until this issue is resolved.

gaelg commented 8 years ago

I tried to work on this, but it's harder than I expected. The storage filters are called with source config objects only, so that there is no way to filter out a destination config object using storage filters. I'll try to find another way.

gaelg commented 8 years ago

Here's what I did today: https://github.com/gaelg/drush/commit/44887b11bada471f0fe90a6591abbe7d54c47053 Any help would be very appreciated, specially to improve dependency detection and to make tests.

gaelg commented 8 years ago

I improved dependency detection and fixed a bug. system.menu.devel is still not ignored, but this is because Devel should enforce the dependency for this config (https://www.drupal.org/node/2404447). It seems to work well. Should I make a pull request, or should this still be improved before any pull?

greg-1-anderson commented 8 years ago

Thanks for working on this. I haven't had a chance to review the referenced branch yet, but it is always okay to make a work-in-progress PR.

gaelg commented 8 years ago

It would be nice if someone in this issue queue could write up tests for this. I'll do it when I get time otherwise. The tests could be: For export :

For import :

I said Devel but it might be better to test with a module which has chained dependencies (which one ?).

NB: It make me think that dependent modules should also be ignored, but that might be another issue for later? (it's easy to just add them in the command)

gaelg commented 8 years ago

I made an issue about the devel problem: https://www.drupal.org/node/2663558

nevergone commented 8 years ago

gaelg: not work :(

weitzman commented 8 years ago

Is this issue related to #1964

gaelg commented 8 years ago

Yes, I'm not very used to GitHub. I first made an "issue", and then a related pull request.

flesheater commented 7 years ago

Meanwhile, you may use this tool from here https://github.com/previousnext/drush_cmi_tools It works like charm for me.

stevector commented 7 years ago

While watching this really good presentation on config management from DrupalCon Dublin (https://www.youtube.com/watch?v=57t_CS2wbHI) I learned about Config Split which handles the same use case: https://www.drupal.org/project/config_split

dsdobrzynski commented 7 years ago

@stevector Config Split does resolve this issue on a broader level. I'm currently using it on several projects successfully. I'm using it to split config based on environment (prod, test/staging, dev) and import based on environment with a script.

Perhaps the larger question then is: Does this need to be part of Drush?

leymannx commented 7 years ago

Sure it does. Drush allows you to skip modules like when you have the following in your drushrc.php for example:

// Ignore development modules when exporting/importing configuration.
$development_modules = ['devel', 'webprofiler'];
$command_specific['config-export']['skip-modules'] = $development_modules;
$command_specific['config-import']['skip-modules'] = $development_modules;

This prevents that these module will get added to core.extensions.yml. So why not skip the other *.yml files related to these modules, too? (Which in this example at least are devel.settings.yml and webprofiler.config.yml.)

rodrigoaguilera commented 7 years ago

The "skip-modules" option was removed on drush 8.1.11 https://github.com/drush-ops/drush/releases/tag/8.1.11

This issue should be closed

colans commented 7 years ago

It was removed in favour of Config Split so yes, we can close this.

leymannx commented 7 years ago

Wow, good to know. Thanks for the clarification.