Unverified Commit 661d8a83 authored by alexpott's avatar alexpott
Browse files

Revert "Issue #2780869 by claudiu.cristea, Lendude, joachim, jmadden27: Cannot...

Revert "Issue #2780869 by claudiu.cristea, Lendude, joachim, jmadden27: Cannot save a view where a filter value option contains a period"

This reverts commit 104bca1e.
parent 23eaaf18
......@@ -635,8 +635,8 @@ display:
admin_label: ''
operator: in
value:
- editorial-draft
- editorial-archived
editorial-draft: editorial-draft
editorial-archived: editorial-archived
group: 1
exposed: true
expose:
......@@ -722,7 +722,7 @@ display:
admin_label: ''
operator: 'not in'
value:
- editorial-published
editorial-published: editorial-published
group: 1
exposed: false
expose:
......
......@@ -209,7 +209,7 @@ display:
admin_label: ''
operator: in
value:
- '***LANGUAGE_language_content***'
'***LANGUAGE_language_content***': '***LANGUAGE_language_content***'
group: 1
exposed: false
expose:
......
......@@ -123,7 +123,7 @@ display:
admin_label: ''
operator: in
value:
- '***LANGUAGE_language_content***'
'***LANGUAGE_language_content***': '***LANGUAGE_language_content***'
group: 1
exposed: false
expose:
......
......@@ -209,7 +209,7 @@ display:
admin_label: ''
operator: in
value:
- '***LANGUAGE_language_content***'
'***LANGUAGE_language_content***': '***LANGUAGE_language_content***'
group: 1
exposed: false
expose:
......
......@@ -132,7 +132,7 @@ display:
admin_label: ''
operator: in
value:
- '***LANGUAGE_language_content***'
'***LANGUAGE_language_content***': '***LANGUAGE_language_content***'
group: 1
exposed: false
expose:
......
......@@ -316,7 +316,7 @@ display:
admin_label: ''
operator: in
value:
- '***LANGUAGE_language_content***'
'***LANGUAGE_language_content***': '***LANGUAGE_language_content***'
group: 1
exposed: false
expose:
......
......@@ -180,7 +180,7 @@ display:
table: node_field_data
field: type
value:
- page
page: page
plugin_id: bundle
entity_type: node
entity_field: type
......@@ -193,9 +193,9 @@ display:
admin_label: ''
operator: in
value:
- fr
- es
- und
fr: fr
es: es
und: und
group: 1
exposed: false
expose:
......
......@@ -105,7 +105,7 @@ display:
admin_label: ''
operator: in
value:
- article
article: article
group: 1
exposed: false
expose:
......
......@@ -105,7 +105,7 @@ display:
admin_label: ''
operator: in
value:
- article
article: article
group: 1
exposed: false
expose:
......
......@@ -105,8 +105,8 @@ display:
admin_label: ''
operator: or
value:
- man
- woman
man: man
woman: woman
group: 1
exposed: false
expose:
......@@ -145,7 +145,7 @@ display:
admin_label: ''
operator: in
value:
- article
article: article
group: 1
exposed: false
expose:
......
......@@ -107,28 +107,6 @@ public function testViewsTestOptionsListGroupedFilter() {
$column_map = ['nid' => 'nid'];
$this->assertIdenticalResultset($view, $resultset, $column_map);
$view->destroy();
$view = Views::getView('test_options_list_filter');
$view->setDisplay();
// Add a filter with a period in the options.
$view->displayHandlers->get('default')->overrideOption('filters', [
'field_test_list_string_value' => [
'id' => 'field_test_list_string_value',
'table' => 'field_data_field_test_list_string',
'field' => 'field_test_list_string_value',
'relationship' => 'none',
'group_type' => 'group',
'admin_label' => '',
'operator' => 'or',
'value' => [$this->fieldValues[2] => $this->fieldValues[2]],
'exposed' => FALSE,
'plugin_id' => 'list_field',
],
]);
$view->save();
$this->executeView($view);
}
}
......@@ -84,7 +84,6 @@ protected function mockStandardInstall() {
$this->fieldValues = [
$this->randomMachineName(),
$this->randomMachineName(),
'option.with.periods',
];
$this->fieldNames = ['field_test_list_string', 'field_test_list_integer'];
......@@ -99,7 +98,6 @@ protected function mockStandardInstall() {
'allowed_values' => [
$this->fieldValues[0] => $this->fieldValues[0],
$this->fieldValues[1] => $this->fieldValues[1],
$this->fieldValues[2] => $this->fieldValues[2],
],
],
])->save();
......@@ -112,7 +110,6 @@ protected function mockStandardInstall() {
'allowed_values' => [
$this->fieldValues[0],
$this->fieldValues[1],
$this->fieldValues[2],
],
],
])->save();
......
......@@ -205,7 +205,7 @@ display:
table: node_field_data
field: type
value:
- article
article: article
entity_type: node
entity_field: type
plugin_id: bundle
......
......@@ -147,7 +147,7 @@ display:
table: node_field_data
field: type
value:
- article
article: article
entity_type: node
entity_field: type
plugin_id: bundle
......
......@@ -142,7 +142,7 @@ display:
admin_label: ''
operator: in
value:
- '***LANGUAGE_language_content***'
'***LANGUAGE_language_content***': '***LANGUAGE_language_content***'
group: 1
exposed: false
expose:
......
......@@ -94,7 +94,7 @@ display:
admin_label: ''
operator: or
value:
- access user profiles
'access user profiles': 'access user profiles'
group: 1
exposed: false
expose:
......
......@@ -54,7 +54,7 @@ public function testDependencies() {
'table' => 'user__roles',
'field' => 'roles_target_id',
'value' => [
'test_user_role',
'test_user_role' => 'test_user_role',
],
'operator' => 'empty',
'plugin_id' => 'user_roles',
......@@ -70,7 +70,7 @@ public function testDependencies() {
'table' => 'user__roles',
'field' => 'roles_target_id',
'value' => [
'test_user_role',
'test_user_role' => 'test_user_role',
],
'operator' => 'not empty',
'plugin_id' => 'user_roles',
......
......@@ -128,7 +128,7 @@ public function calculateDependencies() {
$bundle_entity_type = $this->entityType->getBundleEntityType();
$bundle_entity_storage = $this->entityTypeManager->getStorage($bundle_entity_type);
foreach ($this->value as $bundle) {
foreach (array_keys($this->value) as $bundle) {
if ($bundle_entity = $bundle_entity_storage->load($bundle)) {
$dependencies[$bundle_entity->getConfigDependencyKey()][] = $bundle_entity->getConfigDependencyName();
}
......
......@@ -208,7 +208,7 @@ protected function valueForm(&$form, FormStateInterface $form_state) {
}
if (empty($this->options['expose']['multiple'])) {
if (empty($this->options['expose']['required']) && (empty($default_value) || !empty($this->options['expose']['reduce'])) || in_array('all', $this->options['value'], TRUE)) {
if (empty($this->options['expose']['required']) && (empty($default_value) || !empty($this->options['expose']['reduce'])) || isset($this->options['value']['all'])) {
$default_value = 'All';
}
elseif (empty($default_value)) {
......@@ -275,11 +275,11 @@ public function reduceValueOptions($input = NULL) {
elseif (is_object($option) && !$option instanceof MarkupInterface) {
$keys = array_keys($option->option);
$key = array_shift($keys);
if (in_array($key, $this->options['value'], TRUE)) {
if (isset($this->options['value'][$key])) {
$options[$id] = $option;
}
}
elseif (in_array($id, $this->options['value'], TRUE)) {
elseif (isset($this->options['value'][$id])) {
$options[$id] = $option;
}
}
......@@ -316,7 +316,8 @@ protected function valueSubmit($form, FormStateInterface $form_state) {
// Luckily, the '#value' on the checkboxes form actually contains
// *only* a list of checkboxes that were set, and we can use that
// instead.
$form_state->setValue(['options', 'value'], array_values($form['value']['#value']));
$form_state->setValue(['options', 'value'], $form['value']['#value']);
}
public function adminSummary() {
......
......@@ -10,8 +10,6 @@
use Drupal\Core\Entity\EntityTypeManagerInterface;
use Drupal\Core\Entity\FieldableEntityInterface;
use Drupal\Core\Entity\Sql\DefaultTableMapping;
use Drupal\views\Plugin\views\filter\InOperator;
use Drupal\views\Plugin\ViewsHandlerManager;
use Symfony\Component\DependencyInjection\ContainerInterface;
/**
......@@ -59,13 +57,6 @@ class ViewsConfigUpdater implements ContainerInjectionInterface {
*/
protected $multivalueBaseFieldsUpdateTableInfo;
/**
* The Views filter plugin manager service.
*
* @var \Drupal\views\Plugin\ViewsHandlerManager
*/
protected $filterPluginManager;
/**
* Flag determining whether deprecations should be triggered.
*
......@@ -91,21 +82,17 @@ class ViewsConfigUpdater implements ContainerInjectionInterface {
* The typed config manager.
* @param \Drupal\views\ViewsData $views_data
* The views data service.
* @param \Drupal\views\Plugin\ViewsHandlerManager $filter_plugin_manager
* The Views filter plugin manager service.
*/
public function __construct(
EntityTypeManagerInterface $entity_type_manager,
EntityFieldManagerInterface $entity_field_manager,
TypedConfigManagerInterface $typed_config_manager,
ViewsData $views_data,
ViewsHandlerManager $filter_plugin_manager
ViewsData $views_data
) {
$this->entityTypeManager = $entity_type_manager;
$this->entityFieldManager = $entity_field_manager;
$this->typedConfigManager = $typed_config_manager;
$this->viewsData = $views_data;
$this->filterPluginManager = $filter_plugin_manager;
}
/**
......@@ -116,8 +103,7 @@ public static function create(ContainerInterface $container) {
$container->get('entity_type.manager'),
$container->get('entity_field.manager'),
$container->get('config.typed'),
$container->get('views.views_data'),
$container->get('plugin.manager.views.filter')
$container->get('views.views_data')
);
}
......@@ -152,9 +138,6 @@ public function updateAll(ViewEntityInterface $view) {
if ($this->processMultivalueBaseFieldHandler($handler, $handler_type, $key, $display_id, $view)) {
$changed = TRUE;
}
if ($this->processInOperatorFilterValues($handler, $handler_type)) {
$changed = TRUE;
}
return $changed;
});
}
......@@ -494,49 +477,4 @@ protected function mapOperatorFromSingleToMultiple($single_operator) {
}
}
/**
* Update values for of in_operators filters.
*
* @param \Drupal\views\ViewEntityInterface $view
* The View to update.
*
* @return bool
* Whether the view was updated.
*/
public function needsInOperatorFilterValuesUpdate(ViewEntityInterface $view): bool {
return $this->processDisplayHandlers($view, TRUE, function (array &$handler, string $handler_type): bool {
return $this->processInOperatorFilterValues($handler, $handler_type);
});
}
/**
* Processes the in_operator filter values.
*
* @param array $handler
* A display handler.
* @param string $handler_type
* The handler type.
*
* @return bool
* Whether the handler was updated.
*
* @throws \Drupal\Component\Plugin\Exception\PluginException
* If the filter plugin instance cannot be created.
*/
protected function processInOperatorFilterValues(array &$handler, string $handler_type): bool {
if ($handler_type === 'filter' && !empty($handler['value']) && is_array($handler['value'])) {
$values = array_values($handler['value']);
// Only process if the keys are the same as the values.
if ($values === array_keys($handler['value'])) {
$class = $this->filterPluginManager->getDefinition($handler['plugin_id'])['class'];
// Process for 'in_operator' plugin but also for its descendants.
if ($class === InOperator::class || is_subclass_of($class, InOperator::class)) {
$handler['value'] = $values;
return TRUE;
}
}
}
return FALSE;
}
}
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment