Skip to content
Snippets Groups Projects
Verified Commit a9ebc013 authored by Lee Rowlands's avatar Lee Rowlands
Browse files

Issue #2979821 by alexpott, larowlan:...

Issue #2979821 by alexpott, larowlan: \Drupal\config\Form\ConfigSync::processBatch() merges errors incorrectly
parent a46c4619
No related branches found
No related tags found
2 merge requests!7452Issue #1797438. HTML5 validation is preventing form submit and not fully...,!789Issue #3210310: Adjust Database API to remove deprecated Drupal 9 code in Drupal 10
......@@ -380,7 +380,7 @@ public static function processBatch(ConfigImporter $config_importer, $sync_step,
if (!isset($context['results']['errors'])) {
$context['results']['errors'] = [];
}
$context['results']['errors'] += $errors;
$context['results']['errors'] = array_merge($context['results']['errors'], $errors);
}
}
......
......@@ -5,6 +5,8 @@
* Provides configuration import test helpers.
*/
use Drupal\Core\Config\ConfigImporter;
/**
* Implements hook_config_import_steps_alter().
*/
......@@ -17,9 +19,15 @@ function config_import_test_config_import_steps_alter(&$sync_steps) {
*
* @param array $context
* The batch context.
* @param \Drupal\Core\Config\ConfigImporter $config_importer
* The configuration importer.
*/
function _config_import_test_config_import_steps_alter(&$context) {
function _config_import_test_config_import_steps_alter(&$context, ConfigImporter $config_importer) {
$GLOBALS['hook_config_test']['config_import_steps_alter'] = TRUE;
if (\Drupal::state()->get('config_import_steps_alter.error', FALSE)) {
$context['results']['errors'][] = '_config_import_test_config_import_steps_alter batch error';
$config_importer->logError('_config_import_test_config_import_steps_alter ConfigImporter error');
}
$context['finished'] = 1;
return;
}
......@@ -518,4 +518,17 @@ public function testExtensionValidation() {
$this->assertText('Unable to install the does_not_exist theme since it does not exist.');
}
/**
* Tests that errors set in the batch and on the ConfigImporter are merged.
*/
public function testBatchErrors() {
$new_site_name = 'Config import test ' . $this->randomString();
$this->prepareSiteNameUpdate($new_site_name);
\Drupal::state()->set('config_import_steps_alter.error', TRUE);
$this->drupalPostForm('admin/config/development/configuration', [], t('Import all'));
$this->assertSession()->responseContains('_config_import_test_config_import_steps_alter batch error');
$this->assertSession()->responseContains('_config_import_test_config_import_steps_alter ConfigImporter error');
$this->assertSession()->responseContains('The configuration was imported with errors.');
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment