Skip to content
Snippets Groups Projects
Verified Commit 17ef0c25 authored by Alex Pott's avatar Alex Pott
Browse files

Issue #3427118 by alexpott, phenaproxima, millnut, Wim Leers: If config...

Issue #3427118 by alexpott, phenaproxima, millnut, Wim Leers: If config rollback fails validation, it's impossible to tell what caused the rollback in the first place

(cherry picked from commit 2cf80c1e475acc55aced19db9a7a8375a75eb912)
parent 387bb4eb
No related branches found
No related tags found
1 merge request!7908Recipes API on 10.3.x
......@@ -6,6 +6,7 @@
use Drupal\Core\Config\Checkpoint\Checkpoint;
use Drupal\Core\Config\ConfigImporter;
use Drupal\Core\Config\ConfigImporterException;
use Drupal\Core\Config\StorageComparer;
use Drupal\Core\DrupalKernel;
use Drupal\Core\Site\Settings;
......@@ -87,7 +88,12 @@ protected function execute(InputInterface $input, OutputInterface $output): int
return 0;
}
catch (\Throwable $e) {
$this->rollBackToCheckpoint($backup_checkpoint);
try {
$this->rollBackToCheckpoint($backup_checkpoint);
}
catch (ConfigImporterException $importer_exception) {
$io->error($importer_exception->getMessage());
}
throw $e;
}
}
......
......@@ -77,6 +77,20 @@ public function testRecipeCommand(): void {
$this->assertStringContainsString('[notice] A backup checkpoint was not created because nothing has changed since the "Test log message" checkpoint was created.', $process->getOutput());
}
/**
* Tests that errors during config rollback won't steamroll validation errors.
*/
public function testExceptionOnRollback(): void {
$process = $this->applyRecipe('core/tests/fixtures/recipes/config_rollback_exception', 1);
// The error from the config importer should be visible.
$output = $process->getOutput();
$this->assertStringContainsString('There were errors validating the config synchronization.', $output);
$this->assertStringContainsString('Provides a filter plugin that is in use', $output);
// And the exception that actually *caused* the error should be visible too.
$this->assertStringContainsString('There were validation errors in system.image:', $process->getErrorOutput());
}
/**
* Asserts that the current set of checkpoints matches the given labels.
*
......
name: Config rollback exception
install:
- filter
- media
config:
import:
filter: '*'
media: '*'
actions:
filter.format.plain_text:
setFilterConfig:
instance_id: media_embed
configuration: []
system.image:
# This will cause a validation error, which will trigger a rollback.
# The rollback should fail, since the Media module can't be uninstalled
# now that the plain_text format is using one of its filters.
simple_config_update:
non_existent_key: whatever!
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment