diff --git a/core/lib/Drupal/Core/Config/ConfigManager.php b/core/lib/Drupal/Core/Config/ConfigManager.php index e4ebbd2..49f406d 100644 --- a/core/lib/Drupal/Core/Config/ConfigManager.php +++ b/core/lib/Drupal/Core/Config/ConfigManager.php @@ -350,7 +350,7 @@ public function getConfigEntitiesToChange($operation, $type, array $names, $dry_ } // Now that we've fixed all the possible dependencies, for the remaining we - // need to apply the default action depending on the opeartion. + // need to apply the default action depending on the operation. if ($operation == ConfigManagerInterface::REMOVE) { // On remove the default action of unresolved dependencies is deletion. // Reverse the deletes so that entities are removed in the correct order diff --git a/core/lib/Drupal/Core/Config/Entity/ConfigEntityBase.php b/core/lib/Drupal/Core/Config/Entity/ConfigEntityBase.php index 14eb02f..431d0b3 100644 --- a/core/lib/Drupal/Core/Config/Entity/ConfigEntityBase.php +++ b/core/lib/Drupal/Core/Config/Entity/ConfigEntityBase.php @@ -364,9 +364,11 @@ public function preSave(EntityStorageInterface $storage) { $this->calculateDependencies(); // Fix any dependencies. $config_entities = $this->getConfigManager()->getConfigEntitiesToChange(ConfigManagerInterface::UPDATE, 'config', [$this->getConfigDependencyName() => $this], FALSE); - /** @var \Drupal\Core\Config\Entity\ConfigEntityInterface $dependent_entity */ - foreach ($config_entities['update'] as $dependent_entity) { - $dependent_entity->save(); + if (!empty($config_entities['update'])) { + /** @var \Drupal\Core\Config\Entity\ConfigEntityInterface $dependent_entity */ + foreach ($config_entities['update'] as $dependent_entity) { + $dependent_entity->save(); + } } } } diff --git a/core/tests/Drupal/Tests/Core/Config/Entity/ConfigEntityBaseUnitTest.php b/core/tests/Drupal/Tests/Core/Config/Entity/ConfigEntityBaseUnitTest.php index feca9e9..9e8766c 100644 --- a/core/tests/Drupal/Tests/Core/Config/Entity/ConfigEntityBaseUnitTest.php +++ b/core/tests/Drupal/Tests/Core/Config/Entity/ConfigEntityBaseUnitTest.php @@ -7,6 +7,7 @@ namespace Drupal\Tests\Core\Config\Entity; +use Drupal\Core\Config\ConfigManagerDependencyFinderInterface; use Drupal\Core\DependencyInjection\ContainerBuilder; use Drupal\Core\Language\Language; use Drupal\Tests\Core\Plugin\Fixtures\TestConfigurablePlugin; @@ -132,6 +133,8 @@ protected function setUp() { $container->set('language_manager', $this->languageManager); $container->set('cache_tags.invalidator', $this->cacheTagsInvalidator); $container->set('config.typed', $this->typedConfigManager); + $config_manager = $this->getMock(ConfigManagerDependencyFinderInterface::class); + $container->set('config.manager', $config_manager); \Drupal::setContainer($container); $this->entity = $this->getMockForAbstractClass('\Drupal\Core\Config\Entity\ConfigEntityBase', array($values, $this->entityTypeId)); diff --git a/core/tests/Drupal/Tests/Core/Config/Entity/ConfigEntityStorageTest.php b/core/tests/Drupal/Tests/Core/Config/Entity/ConfigEntityStorageTest.php index 508f39b..ecb3788 100644 --- a/core/tests/Drupal/Tests/Core/Config/Entity/ConfigEntityStorageTest.php +++ b/core/tests/Drupal/Tests/Core/Config/Entity/ConfigEntityStorageTest.php @@ -8,6 +8,7 @@ namespace Drupal\Tests\Core\Config\Entity { use Drupal\Core\Cache\Cache; +use Drupal\Core\Config\ConfigManager; use Drupal\Core\Config\Entity\ConfigEntityInterface; use Drupal\Core\Entity\EntityInterface; use Drupal\Core\Language\Language; @@ -176,7 +177,9 @@ protected function setUp() { ->method('getDefinition') ->will($this->returnValue(array('mapping' => array('id' => '', 'uuid' => '', 'dependencies' => '')))); - $this->configManager = $this->getMock('Drupal\Core\Config\ConfigManagerInterface'); + $this->configManager = $this->getMockBuilder(ConfigManager::class) + ->disableOriginalConstructor() + ->getMock(); $this->cacheContextsManager = $this->getMockBuilder('Drupal\Core\Cache\Context\CacheContextsManager') ->disableOriginalConstructor()