Issue #2979821 by alexpott, larowlan: \Drupal\config\Form\ConfigSync::processBatch() merges errors incorrectly
parent
a46c46194d
commit
a9ebc01372
|
@ -380,7 +380,7 @@ class ConfigSync extends FormBase {
|
|||
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 @@ class ConfigImportUITest extends BrowserTestBase {
|
|||
$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.');
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue