diff --git a/core/modules/system/system.post_update.php b/core/modules/system/system.post_update.php index d1dc79e..356c420 100644 --- a/core/modules/system/system.post_update.php +++ b/core/modules/system/system.post_update.php @@ -4,9 +4,6 @@ * @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 @@ -41,23 +38,29 @@ function system_post_update_fix_enforced_dependencies() { * * @see https://www.drupal.org/node/2520526 */ -function system_post_update_recalculate_dependencies_for_installed_config_entities() { +function system_post_update_recalculate_dependencies_for_installed_config_entities(&$sandbox = NULL) { + if (!isset($sandbox['config_names'])) { + $sandbox['config_names'] = \Drupal::configFactory()->listAll(); + $sandbox['count'] = count($sandbox['config_names']); + } /** @var \Drupal\Core\Config\ConfigManagerInterface $config_manager */ $config_manager = \Drupal::service('config.manager'); - // Scan all module install folders and resave the entities in there. This - // includes uninstalled modulees too as potentially they provided - // configuration which did not depend on themselves. - $install_storage = new InstallStorage(); - $config_names = $install_storage->listAll(); - $install_storage = new InstallStorage(InstallStorage::CONFIG_OPTIONAL_DIRECTORY); - $config_names = array_merge($config_names, $install_storage->listAll()); - - foreach ($config_names as $config_name) { + $count = 0; + foreach ($sandbox['config_names'] as $key => $config_name) { if ($entity = $config_manager->loadConfigEntityByName($config_name)) { $entity->save(); } + unset($sandbox['config_names'][$key]); + $count++; + // Do 50 at a time. + if ($count == 50) { + break; + } } + + $sandbox['#finished'] = empty($sandbox['config_names']) ? 1 : ($sandbox['count'] - count($sandbox['config_names'])) / $sandbox['count']; + return t('Configuration dependencies recalculated'); } /**