Commit 2c313d68 authored by catch's avatar catch
Browse files

Issue #3405798 by alexpott, bircher: Config deleted during import does not...

Issue #3405798 by alexpott, bircher: Config deleted during import does not have correct initial values set

(cherry picked from commit cf5e2c17)
parent 84181889
Loading
Loading
Loading
Loading
Loading
+3 −3
Original line number Diff line number Diff line
@@ -992,13 +992,13 @@ protected function importConfig($collection, $op, $name) {
    else {
      $config = new Config($name, $this->storageComparer->getTargetStorage($collection), $this->eventDispatcher, $this->typedConfigManager);
    }
    if ($old_data = $this->storageComparer->getTargetStorage($collection)->read($name)) {
      $config->initWithData($old_data);
    }
    if ($op == 'delete') {
      $config->delete();
    }
    else {
      if ($old_data = $this->storageComparer->getTargetStorage($collection)->read($name)) {
        $config->initWithData($old_data);
      }
      $data = $this->storageComparer->getSourceStorage($collection)->read($name);
      $config->setData($data ? $data : []);
      $config->save();
+10 −0
Original line number Diff line number Diff line
@@ -918,6 +918,16 @@ public function testConfigEvents(): void {
    $this->assertSame(['key' => 'bar'], $event['current_config_data']);
    $this->assertSame(['key' => 'bar'], $event['raw_config_data']);
    $this->assertSame(['key' => 'foo'], $event['original_config_data']);

    // Import the configuration that deletes 'config_events_test.test'.
    $this->container->get('config.storage.sync')->delete('config_events_test.test');
    $this->configImporter()->import();
    $this->assertFalse($this->container->get('config.storage')->exists('config_events_test.test'));
    $event = \Drupal::state()->get('config_events_test.event', []);
    $this->assertSame(ConfigEvents::DELETE, $event['event_name']);
    $this->assertSame([], $event['current_config_data']);
    $this->assertSame([], $event['raw_config_data']);
    $this->assertSame(['key' => 'bar'], $event['original_config_data']);
  }

  /**