diff --git a/core/modules/views/views.install b/core/modules/views/views.install index 995fa17..03d9e72 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\Core\Config\Schema\ArrayElement; use Drupal\views\Views; /** @@ -500,19 +501,6 @@ function views_update_8300() { $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_type_singular]['id']); - // Filter values we want to convert from a string to an array. - 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'] === '') { - $data['value'] = []; - } - else { - $data['value'] = (array) $data['value']; - } - $view->set("{$path_to_handler}.value", $data['value']); - } - $changed = TRUE; } } @@ -535,11 +523,24 @@ function views_update_8300() { $typed_view = $typed_config_manager->get($id); $view = $config_factory->getEditable($id); - // For all the other fields we try to determine the fields using - // config schema and remove everything which is not needed. /** @var \Drupal\Core\Config\Schema\ArrayElement $typed_config */ $typed_config = $typed_view->get($path_to_handler); $config = $typed_config->getValue(); + + // Filter values we want to convert from a string to an array. + if (strpos($path_to_handler, 'filters') !== 0 && $typed_config->getDataDefinition()['mapping']['value'] instanceof ArrayElement && is_string($config['value'])) { + // An empty string casted to an array is an array with one + // element. + if ($config['value'] === '') { + $config['value'] = []; + } + else { + $config['value'] = (array) $config['value']; + } + } + + // For all the other fields we try to determine the fields using + // config schema and remove everything which is not needed. foreach (array_keys($config) as $config_key) { if (!isset($typed_config->getDataDefinition()['mapping'][$config_key])) { unset($config[$config_key]);