diff --git a/core/modules/system/src/Tests/Update/RecalculatedDependencyTest.php b/core/modules/system/src/Tests/Update/RecalculatedDependencyTest.php new file mode 100644 index 0000000..36fa215 --- /dev/null +++ b/core/modules/system/src/Tests/Update/RecalculatedDependencyTest.php @@ -0,0 +1,45 @@ +databaseDumpFiles = [ + __DIR__ . '/../../../tests/fixtures/update/drupal-8.bare.standard.php.gz', + ]; + } + + /** + * Ensures that the entities are resaved so they have the new dependency. + */ + public function testUpdate() { + $this->runUpdates(); + + $data = \Drupal::config('field.field.node.article.field_tags')->get(); + $this->assertEqual(['taxonomy'], $data['dependencies']['module']); + + $data = \Drupal::config('field.field.user.user.user_picture')->get(); + $this->assertEqual(['file', 'image', 'user'], $data['dependencies']['module']); + + $data = \Drupal::config('field.storage.node.field_image')->get(); + $this->assertEqual(['image', 'node'], $data['dependencies']['module']); + + $data = \Drupal::config('field.storage.node.field_tags')->get(); + $this->assertEqual(['node'], $data['dependencies']['module']); + } + +} diff --git a/core/modules/system/system.post_update.php b/core/modules/system/system.post_update.php index 3a141ce..46cfda2 100644 --- a/core/modules/system/system.post_update.php +++ b/core/modules/system/system.post_update.php @@ -4,6 +4,9 @@ * @file * Post update functions for System. */ +use Drupal\Core\Config\FileStorage; +use Drupal\Core\Config\InstallStorage; +use Drupal\Core\Config\StorageInterface; /** * @addtogroup updates-8.0.0-beta @@ -31,5 +34,30 @@ function system_post_update_fix_enforced_dependencies() { } /** + * Re-save all config entities that got installed at some point. + * + * Drupal forgot to recalculate the dependencies for them, + * see https://www.drupal.org/node/2520526, so we resave to recalculate them. + */ +function system_post_update_recalculate_dependencies_for_installed_config_entities() { + /** @var \Drupal\Core\Config\ConfigManagerInterface $config_manager */ + $config_manager = \Drupal::service('config.manager'); + + // Loads scan all module install folders and resave the entities in there. + $modules = array_keys(\Drupal::moduleHandler()->getModuleList()); + foreach ($modules as $module) { + $default_install_path = drupal_get_path('module', $module) . '/' . InstallStorage::CONFIG_INSTALL_DIRECTORY; + $storage = new FileStorage($default_install_path, StorageInterface::DEFAULT_COLLECTION); + $config_names = $storage->listAll(); + + foreach ($config_names as $config_name) { + if ($entity = $config_manager->loadConfigEntityByName($config_name)) { + $entity->save(); + } + } + } +} + +/** * @} End of "addtogroup updates-8.0.0-beta". */ diff --git a/core/profiles/standard/config/install/field.field.node.article.field_tags.yml b/core/profiles/standard/config/install/field.field.node.article.field_tags.yml index 5bb0833..291b5e9 100644 --- a/core/profiles/standard/config/install/field.field.node.article.field_tags.yml +++ b/core/profiles/standard/config/install/field.field.node.article.field_tags.yml @@ -5,7 +5,6 @@ dependencies: - field.storage.node.field_tags - node.type.article module: - - entity_reference - taxonomy id: node.article.field_tags field_name: field_tags diff --git a/core/profiles/standard/config/install/field.storage.node.field_tags.yml b/core/profiles/standard/config/install/field.storage.node.field_tags.yml index 16cd3ed..69b9edc 100644 --- a/core/profiles/standard/config/install/field.storage.node.field_tags.yml +++ b/core/profiles/standard/config/install/field.storage.node.field_tags.yml @@ -2,7 +2,6 @@ langcode: en status: true dependencies: module: - - entity_reference - node id: node.field_tags field_name: field_tags