When creating a Split Setting the Static/Folder field says that it is permissible to leave the folder blank and those configurations won't be written. If Split setting has a folder defined, but the folder doesn't exist the following error is return on config-export
exception 'InvalidArgumentException' with message 'The split storage has to be set and exist for write operations.' in /var/www/docroot/sites/default/modules/config_split/src/Plugin/ConfigFilter/SplitFilter.php:167 [error]
Stack trace:
#0 /var/www/docroot/sites/default/modules/config_filter/src/Config/FilteredStorage.php(93): Drupal\config_split\Plugin\ConfigFilter\SplitFilter->filterWrite('action.settings', Array)
#1 phar:///usr/local/bin/drush/commands/core/config.drush.inc(507): Drupal\config_filter\Config\FilteredStorage->write('action.settings', Array)
#2 phar:///usr/local/bin/drush/commands/core/config.drush.inc(445): _drush_config_export('sync', 'profiles/oig_go...', false)
#3 [internal function]: drush_config_export()
#4 phar:///usr/local/bin/drush/includes/command.inc(422): call_user_func_array('drush_config_ex...', Array)
#5 phar:///usr/local/bin/drush/includes/command.inc(231): _drush_invoke_hooks(Array, Array)
#6 [internal function]: drush_command()
#7 phar:///usr/local/bin/drush/includes/command.inc(199): call_user_func_array('drush_command', Array)
#8 phar:///usr/local/bin/drush/lib/Drush/Boot/BaseBoot.php(67): drush_dispatch(Array)
#9 phar:///usr/local/bin/drush/includes/preflight.inc(66): Drush\Boot\BaseBoot->bootstrap_and_dispatch()
#10 phar:///usr/local/bin/drush/includes/startup.inc(458): drush_main()
#11 phar:///usr/local/bin/drush/includes/startup.inc(365): drush_run_main(false, '/', 'Phar detected. ...')
#12 phar:///usr/local/bin/drush/drush(114): drush_startup(Array)
#13 /usr/local/bin/drush(10): require('phar:///usr/loc...')
#14 {main}
This causes the config-export to fail.
I see two possible solutions...
- Upon form submission and validation verify the directory exists and warn the user to create it.
- Change the error message that shows on the command line to actually say "The destination directory /var/www/path/to/directory doesn't exist so we cannot save the configuration export."
| Comment | File | Size | Author |
|---|---|---|---|
| #4 | config_split-config-dir-exits-2906189-4-D8.patch | 848 bytes | cristiroma |
Comments
Comment #2
bircherHi
Thanks for opening this issue, however this is not a bug. The export fails as expected when the directory doesn't exist.
I agree that the message could be improved and we could even throw a custom exception. (This would still print the stack trace depending on your settings.) I don't have strong feelings on what the message should be.
Warning that the folder doesn't exist on the form submission is also a good idea but there are legitimate cases when the folder doesn't exist so I would not impede the form submission in such cases. (The folder property is overwritten in settings.php for example).
Comment #3
cristiroma commentedComment #4
cristiroma commentedAttaching a patch that checks the directory really exists and is writable. If not it shows an warning like
"The storage path /path/to/drupal/test_split for test_split Configuration Split Setting does not exists or is not writable."
Comment #6
bircherThanks!
I removed the check if it is writable because the website user which runs the frontend doesn't need to have write access to the folder.