diff --git a/core/modules/user/src/Plugin/views/filter/Roles.php b/core/modules/user/src/Plugin/views/filter/Roles.php index 6a75fa9..f9a6720 100644 --- a/core/modules/user/src/Plugin/views/filter/Roles.php +++ b/core/modules/user/src/Plugin/views/filter/Roles.php @@ -75,8 +75,9 @@ function operators() { public function calculateDependencies() { $dependencies = array(); - // Due to a bug $this->value might be a string. In the empty case stop - // early. Otherwise we cast it to an array later. + // Due to a bug $this->value might be a string, see + // https://www.drupal.org/node/2846614. In the empty case stop early. + // Otherwise we cast it to an array later. if (is_string($this->value) && $this->value === '') { return []; } diff --git a/core/modules/views/views.install b/core/modules/views/views.install index a469752..995fa17 100644 --- a/core/modules/views/views.install +++ b/core/modules/views/views.install @@ -4,6 +4,7 @@ * @file * Contains install and update functions for Views. */ +use Drupal\views\Views; /** * Implements hook_install(). @@ -462,21 +463,18 @@ function views_update_8300() { $config_factory = \Drupal::configFactory(); /** @var \Drupal\Core\Config\TypedConfigManagerInterface $typed_config_manager */ $typed_config_manager = \Drupal::service('config.typed'); - $views_data = \Drupal\views\Views::viewsData(); - $handler_types_plural = ['fields', 'arguments', 'sorts', 'relationships', 'filters']; - $handler_types_singular = array_map(function ($handler_type) { - return substr($handler_type, 0, -1); - }, array_combine($handler_types_plural, $handler_types_plural)); + $views_data = Views::viewsData(); + $handler_types = ['field', 'argument', 'sort', 'relationship', 'filter']; $required_cleanup_handlers = []; foreach ($config_factory->listAll('views.view.') as $id) { $view = $config_factory->getEditable($id); - /** @var \Drupal\Core\Config\Schema\TypedConfigInterface $typed_view */ $changed = FALSE; foreach ($view->get('display') as $display_id => &$display) { - foreach ($handler_types_plural as $handler_type) { - $handler_data = $view->get("display.$display_id.display_options.$handler_type"); + foreach ($handler_types as $handler_type_singular) { + $handler_type_plural = $handler_type_singular . 's'; + $handler_data = $view->get("display.$display_id.display_options.$handler_type_plural"); if (empty($handler_data)) { continue; @@ -487,7 +485,7 @@ function views_update_8300() { // name. $table = $data['table']; if (isset($table_update_info[$table])) { - $path_to_handler = "display.$display_id.display_options.$handler_type.$key"; + $path_to_handler = "display.$display_id.display_options.$handler_type_plural.$key"; $path_field = "{$path_to_handler}.field"; $path_plugin_id = "{$path_to_handler}.plugin_id"; $original_field_name = $view->get($path_field); @@ -500,10 +498,10 @@ function views_update_8300() { // Set both the new table field as well as new 'plugin_id' field. $view->set($path_field, $table_update_info[$table][$original_field_name]); - $view->set($path_plugin_id, $views_data->get($table)[$table_update_info[$table][$original_field_name]][$handler_types_singular[$handler_type]]['id']); + $view->set($path_plugin_id, $views_data->get($table)[$table_update_info[$table][$original_field_name]][$handler_type_singular]['id']); // Filter values we want to convert from a string to an array. - if ($handler_type === 'filters' && is_string($data['value'])) { + if ($handler_type_singular === 'filter' && is_string($data['value'])) { // An empty string casted to an array is an array with one // element. if ($data['value'] === '') { @@ -529,8 +527,11 @@ function views_update_8300() { // Beside of updating the field and plugin ID we also need to truncate orphan // keys so he configuration applies to the config schema. + // We cannot do that inline in the other code, due to caching issues with + // typed configuration. foreach ($required_cleanup_handlers as list($id, $path_to_handler)) { $changed = FALSE; + /** @var \Drupal\Core\Config\Schema\TypedConfigInterface $typed_view */ $typed_view = $typed_config_manager->get($id); $view = $config_factory->getEditable($id); @@ -552,8 +553,6 @@ function views_update_8300() { $view->save(); } } - - } /**