diff --git a/src/Drupal/Driver/Cores/Drupal8.php b/src/Drupal/Driver/Cores/Drupal8.php index 13234163..119bac2d 100644 --- a/src/Drupal/Driver/Cores/Drupal8.php +++ b/src/Drupal/Driver/Cores/Drupal8.php @@ -520,8 +520,8 @@ public function startCollectingMail() { $config = \Drupal::configFactory()->getEditable('system.mail'); $data = $config->getRawData(); - // Save the original values for restoration after. - $this->originalConfiguration['system.mail'] = $data; + // Save the values for restoration after. + $this->storeOriginalConfiguration('system.mail', $data); // @todo Use a collector that supports html after D#2223967 lands. $data['interface'] = ['default' => 'test_mail_collector']; @@ -583,7 +583,7 @@ protected function startCollectingMailSystemMail() { $data = $config->getRawData(); // Track original data for restoration. - $this->originalConfiguration['mailsystem.settings'] = $data; + $this->storeOriginalConfiguration('mailsystem.settings', $data); // Convert all of the 'senders' to the test collector. $data = $this->findMailSystemSenders($data); @@ -619,4 +619,20 @@ protected function stopCollectingMailSystemMail() { } } + /** + * Store the original value for a piece of configuration. + * + * If an original value has previously been stored, it is not updated. + * + * @param string $name + * The name of the configuration. + * @param mixed $value + * The original value of the configuration. + */ + protected function storeOriginalConfiguration($name, $value) { + if (!isset($this->originalConfiguration[$name])) { + $this->originalConfiguration[$name] = $value; + } + } + }