Problem/Motivation
drush config:export
(cex) command fails on the site like the following.
- Uses Drush 9
- There are translations of config that are same language in "sync" and splits
For example, config directory is in the following state.
config
├── dev_split
│ └── language
│ └── ja
│ └── SOME_CONFIGS
└── sync
└── language
└── ja
└── SOME_CONFIGS
When executing the drush config:export
command, the following error occurs.
$ drush config:export -v -y
...
In FileStorage.php line 254:
[UnexpectedValueException]
FilesystemIterator::__construct(../config/sync/language/ja): failed to open dir: No such file or directory
Exception trace:
FilesystemIterator->__construct() at web/core/lib/Drupal/Core/Config/FileStorage.php:254
Drupal\Core\Config\FileStorage->deleteAll() at web/modules/contrib/config_filter/src/Config/FilteredStorage.php:190
Drupal\config_filter\Config\FilteredStorage->deleteAll() at vendor/drush/drush/src/Drupal/Commands/config/ConfigExportCommands.php:142
Drush\Drupal\Commands\config\ConfigExportCommands->doExport() at vendor/drush/drush/src/Drupal/Commands/config/ConfigExportCommands.php:91
Drush\Drupal\Commands\config\ConfigExportCommands->export() at n/a:n/a
...
After that error, YAML files and "ja" dirs has been deleted.
Cause
The cause of the problem is that SplitFilter#filterGetAllCollectionNames()
returns duplicate collection names.
On the above site, SplitFilter#filterGetAllCollectionNames()
returns ['language.ja', 'language.ja']
.
Drush 9 attempts to delete all collections before exporting.
It attempts to delete language.ja
twice, therefore an error occurs on the second deletion.
Drush 8 delete only the default collection, so the problem has not become obvious so far.
Related code of Drush
- Drush 9.5.2: https://github.com/drush-ops/drush/blob/9.5.2/src/Drupal/Commands/config...
- Deletes default collection and all other collections
- Drush 8.1.17: https://github.com/drush-ops/drush/blob/8.1.17/commands/core/config.drus...
- Deletes only default collection
Proposed resolution
The problem is solved if SplitFilter#filterGetAllCollectionNames()
returns unique collection names.
Comment | File | Size | Author |
---|---|---|---|
#2 | config_export_fails_on-3011363-2.patch | 677 bytes | masamoto |
|
Comments
Comment #2
masamoto CreditAttribution: masamoto commentedI fixed and tested by the following versions.
Last commit: Wed Sep 26 16:01:36 2018 +0200 0ef6f0ca8629b89170b7142254c1ec2d76dd766d
Comment #3
rrrob CreditAttribution: rrrob at Chapter Three commentedConfirmed that this patch fixes the issue as described in the issue description.
Comment #4
bircherLooks good, simple yet effective.
It would be great to have a test for this though.
Comment #6
bircherOk so no tests..
Thanks for the contribution!