From eb63731faf6b5a39040e1bbe9d7ec0156cc62ad9 Mon Sep 17 00:00:00 2001 From: Claudiu Cristea Date: Tue, 24 Nov 2020 09:51:31 +0200 Subject: [PATCH 1/4] Patch #2897638-43 --- .../config/optional/views.view.comment.yml | 1 + .../optional/views.view.comments_recent.yml | 4 ++ .../config/optional/views.view.watchdog.yml | 1 + .../config/optional/views.view.media.yml | 1 + .../install/views.view.media_library.yml | 3 ++ .../config/optional/views.view.archive.yml | 1 + .../optional/views.view.content_recent.yml | 1 + .../config/optional/views.view.frontpage.yml | 2 + .../optional/views.view.taxonomy_term.yml | 2 + .../optional/views.view.user_admin_people.yml | 1 + .../config/optional/views.view.who_s_new.yml | 1 + .../optional/views.view.who_s_online.yml | 1 + .../config/schema/views.data_types.schema.yml | 3 ++ .../views/display/DisplayPluginBase.php | 7 +++ .../exposed_form/ExposedFormPluginBase.php | 34 +++++++------- .../src/Plugin/views/sort/SortPluginBase.php | 43 +++++++++++++++++- core/modules/views/src/ViewsConfigUpdater.php | 37 ++++++++++++++++ .../src/Functional/Plugin/ExposedFormTest.php | 17 ++++++- .../Update/ViewsSortIdentifiersUpdateTest.php | 44 +++++++++++++++++++ .../src/Kernel/Plugin/DisplayKernelTest.php | 13 +++++- core/modules/views/views.post_update.php | 13 ++++++ .../views_ui/css/views_ui.admin.theme.css | 2 + .../src/Functional/ExposedFormUITest.php | 37 ++++++++++++++-- .../install/views.view.articles_aside.yml | 2 + .../install/views.view.featured_articles.yml | 2 + .../config/install/views.view.frontpage.yml | 3 ++ .../install/views.view.promoted_items.yml | 1 + .../install/views.view.recipe_collections.yml | 1 + .../config/install/views.view.recipes.yml | 2 + .../install/views.view.taxonomy_term.yml | 2 + .../config/optional/views.view.media.yml | 1 + core/themes/claro/css/components/views-ui.css | 3 ++ .../claro/css/components/views-ui.pcss.css | 3 ++ .../claro/css/theme/views_ui.admin.theme.css | 2 + .../css/theme/views_ui.admin.theme.pcss.css | 2 + core/themes/seven/css/components/views-ui.css | 3 ++ .../css/views_ui/views_ui.admin.theme.css | 2 + .../css/views_ui/views_ui.admin.theme.css | 2 + 38 files changed, 274 insertions(+), 26 deletions(-) create mode 100644 core/modules/views/tests/src/Functional/Update/ViewsSortIdentifiersUpdateTest.php diff --git a/core/modules/comment/config/optional/views.view.comment.yml b/core/modules/comment/config/optional/views.view.comment.yml index 36ab4560168..147b32b587c 100644 --- a/core/modules/comment/config/optional/views.view.comment.yml +++ b/core/modules/comment/config/optional/views.view.comment.yml @@ -806,6 +806,7 @@ display: exposed: false expose: label: '' + identifier: changed granularity: second entity_type: comment entity_field: changed diff --git a/core/modules/comment/config/optional/views.view.comments_recent.yml b/core/modules/comment/config/optional/views.view.comments_recent.yml index 0387a60737d..4382f13b084 100644 --- a/core/modules/comment/config/optional/views.view.comments_recent.yml +++ b/core/modules/comment/config/optional/views.view.comments_recent.yml @@ -206,6 +206,7 @@ display: exposed: false expose: label: '' + identifier: created plugin_id: date entity_type: comment entity_field: created @@ -218,6 +219,9 @@ display: admin_label: '' order: DESC exposed: false + expose: + label: '' + identifier: cid plugin_id: field entity_type: comment entity_field: cid diff --git a/core/modules/dblog/config/optional/views.view.watchdog.yml b/core/modules/dblog/config/optional/views.view.watchdog.yml index e6542aa9d44..1bffe2c9c02 100644 --- a/core/modules/dblog/config/optional/views.view.watchdog.yml +++ b/core/modules/dblog/config/optional/views.view.watchdog.yml @@ -647,6 +647,7 @@ display: exposed: false expose: label: '' + identifier: wid plugin_id: standard title: 'Recent log messages' header: { } diff --git a/core/modules/media/config/optional/views.view.media.yml b/core/modules/media/config/optional/views.view.media.yml index 17518dc84a5..133f33443a0 100644 --- a/core/modules/media/config/optional/views.view.media.yml +++ b/core/modules/media/config/optional/views.view.media.yml @@ -845,6 +845,7 @@ display: exposed: false expose: label: '' + identifier: created granularity: second title: Media header: { } diff --git a/core/modules/media_library/config/install/views.view.media_library.yml b/core/modules/media_library/config/install/views.view.media_library.yml index 35fd413df8d..e48b104dbb7 100644 --- a/core/modules/media_library/config/install/views.view.media_library.yml +++ b/core/modules/media_library/config/install/views.view.media_library.yml @@ -418,6 +418,7 @@ display: exposed: true expose: label: 'Newest first' + identifier: created granularity: second entity_type: media entity_field: created @@ -433,6 +434,7 @@ display: exposed: true expose: label: 'Name (A-Z)' + identifier: name entity_type: media entity_field: name plugin_id: standard @@ -447,6 +449,7 @@ display: exposed: true expose: label: 'Name (Z-A)' + identifier: name_1 entity_type: media entity_field: name plugin_id: standard diff --git a/core/modules/node/config/optional/views.view.archive.yml b/core/modules/node/config/optional/views.view.archive.yml index b8e55476d14..f020fdef098 100644 --- a/core/modules/node/config/optional/views.view.archive.yml +++ b/core/modules/node/config/optional/views.view.archive.yml @@ -77,6 +77,7 @@ display: exposed: false expose: label: '' + identifier: created granularity: second entity_type: node entity_field: created diff --git a/core/modules/node/config/optional/views.view.content_recent.yml b/core/modules/node/config/optional/views.view.content_recent.yml index 44de40b828f..5e0c0cd7a59 100644 --- a/core/modules/node/config/optional/views.view.content_recent.yml +++ b/core/modules/node/config/optional/views.view.content_recent.yml @@ -254,6 +254,7 @@ display: exposed: false expose: label: '' + identifier: changed granularity: second entity_type: node entity_field: changed diff --git a/core/modules/node/config/optional/views.view.frontpage.yml b/core/modules/node/config/optional/views.view.frontpage.yml index efdae12c186..c4fed0c3243 100644 --- a/core/modules/node/config/optional/views.view.frontpage.yml +++ b/core/modules/node/config/optional/views.view.frontpage.yml @@ -203,6 +203,7 @@ display: admin_label: '' expose: label: '' + identifier: sticky exposed: false field: sticky group_type: group @@ -225,6 +226,7 @@ display: exposed: false expose: label: '' + identifier: created granularity: second entity_type: node entity_field: created diff --git a/core/modules/taxonomy/config/optional/views.view.taxonomy_term.yml b/core/modules/taxonomy/config/optional/views.view.taxonomy_term.yml index 895019632e4..b5806afcf8f 100644 --- a/core/modules/taxonomy/config/optional/views.view.taxonomy_term.yml +++ b/core/modules/taxonomy/config/optional/views.view.taxonomy_term.yml @@ -77,6 +77,7 @@ display: exposed: false expose: label: '' + identifier: sticky created: id: created table: taxonomy_index @@ -89,6 +90,7 @@ display: exposed: false expose: label: '' + identifier: created granularity: second arguments: tid: diff --git a/core/modules/user/config/optional/views.view.user_admin_people.yml b/core/modules/user/config/optional/views.view.user_admin_people.yml index 46a22eba1f3..c028c2a7339 100644 --- a/core/modules/user/config/optional/views.view.user_admin_people.yml +++ b/core/modules/user/config/optional/views.view.user_admin_people.yml @@ -846,6 +846,7 @@ display: exposed: false expose: label: '' + identifier: created granularity: second plugin_id: date entity_type: user diff --git a/core/modules/user/config/optional/views.view.who_s_new.yml b/core/modules/user/config/optional/views.view.who_s_new.yml index 2898850ce67..8656af39087 100644 --- a/core/modules/user/config/optional/views.view.who_s_new.yml +++ b/core/modules/user/config/optional/views.view.who_s_new.yml @@ -156,6 +156,7 @@ display: exposed: false expose: label: '' + identifier: created granularity: second plugin_id: date entity_type: user diff --git a/core/modules/user/config/optional/views.view.who_s_online.yml b/core/modules/user/config/optional/views.view.who_s_online.yml index 2229485cd97..329fece4df0 100644 --- a/core/modules/user/config/optional/views.view.who_s_online.yml +++ b/core/modules/user/config/optional/views.view.who_s_online.yml @@ -165,6 +165,7 @@ display: exposed: false expose: label: '' + identifier: access granularity: second plugin_id: date entity_type: user diff --git a/core/modules/views/config/schema/views.data_types.schema.yml b/core/modules/views/config/schema/views.data_types.schema.yml index 708e12f6d8e..791a8531312 100644 --- a/core/modules/views/config/schema/views.data_types.schema.yml +++ b/core/modules/views/config/schema/views.data_types.schema.yml @@ -281,6 +281,9 @@ views_sort_expose: label: type: label label: 'Label' + identifier: + type: string + label: 'Identifier' views_area: type: views_handler diff --git a/core/modules/views/src/Plugin/views/display/DisplayPluginBase.php b/core/modules/views/src/Plugin/views/display/DisplayPluginBase.php index 0d89fb724be..1ebbf854d8f 100644 --- a/core/modules/views/src/Plugin/views/display/DisplayPluginBase.php +++ b/core/modules/views/src/Plugin/views/display/DisplayPluginBase.php @@ -2559,6 +2559,13 @@ public function newDisplay() { */ public function isIdentifierUnique($id, $identifier) { foreach (ViewExecutable::getHandlerTypes() as $type => $info) { + if ($type === 'sort') { + // The exposed sort identifier is the value of 'sort_by' query string + // parameter and cannot collide with $identifier as the later is used as + // query string parameter key. + continue; + } + foreach ($this->getHandlers($type) as $key => $handler) { if ($handler->canExpose() && $handler->isExposed()) { if ($handler->isAGroup()) { diff --git a/core/modules/views/src/Plugin/views/exposed_form/ExposedFormPluginBase.php b/core/modules/views/src/Plugin/views/exposed_form/ExposedFormPluginBase.php index cfb593d6e66..71a352afc04 100644 --- a/core/modules/views/src/Plugin/views/exposed_form/ExposedFormPluginBase.php +++ b/core/modules/views/src/Plugin/views/exposed_form/ExposedFormPluginBase.php @@ -157,19 +157,17 @@ public function query() { if (!empty($sort_by)) { // Make sure the original order of sorts is preserved // (e.g. a sticky sort is often first) - if (isset($view->sort[$sort_by])) { - $view->query->orderby = []; - foreach ($view->sort as $key => $sort) { - if (!$sort->isExposed()) { - $sort->query(); - } - elseif ($key == $sort_by) { - if (isset($exposed_data['sort_order']) && in_array($exposed_data['sort_order'], ['ASC', 'DESC'])) { - $sort->options['order'] = $exposed_data['sort_order']; - } - $sort->setRelationship(); - $sort->query(); + $view->query->orderby = []; + foreach ($view->sort as $key => $sort) { + if (!$sort->isExposed()) { + $sort->query(); + } + elseif (!empty($sort->options['expose']['identifier']) && $sort->options['expose']['identifier'] === $sort_by) { + if (isset($exposed_data['sort_order']) && in_array($exposed_data['sort_order'], ['ASC', 'DESC'], TRUE)) { + $sort->options['order'] = $exposed_data['sort_order']; } + $sort->setRelationship(); + $sort->query(); } } } @@ -205,16 +203,18 @@ public function exposedFormAlter(&$form, FormStateInterface $form_state) { // Check if there is exposed sorts for this view $exposed_sorts = []; + $exposed_sorts_options = []; foreach ($this->view->sort as $id => $handler) { - if ($handler->canExpose() && $handler->isExposed()) { - $exposed_sorts[$id] = $handler->options['expose']['label']; + if ($handler->canExpose() && $handler->isExposed() && !empty($handler->options['expose']['identifier'])) { + $exposed_sorts[$handler->options['expose']['identifier']] = $id; + $exposed_sorts_options[$handler->options['expose']['identifier']] = $handler->options['expose']['label']; } } if (count($exposed_sorts)) { $form['sort_by'] = [ '#type' => 'select', - '#options' => $exposed_sorts, + '#options' => $exposed_sorts_options, '#title' => $this->options['exposed_sorts_label'], ]; $sort_order = [ @@ -222,8 +222,8 @@ public function exposedFormAlter(&$form, FormStateInterface $form_state) { 'DESC' => $this->options['sort_desc_label'], ]; $user_input = $form_state->getUserInput(); - if (isset($user_input['sort_by']) && isset($this->view->sort[$user_input['sort_by']])) { - $default_sort_order = $this->view->sort[$user_input['sort_by']]->options['order']; + if (isset($user_input['sort_by']) && isset($exposed_sorts[$user_input['sort_by']]) && isset($this->view->sort[$exposed_sorts[$user_input['sort_by']]])) { + $default_sort_order = $this->view->sort[$exposed_sorts[$user_input['sort_by']]]->options['order']; } else { $first_sort = reset($this->view->sort); diff --git a/core/modules/views/src/Plugin/views/sort/SortPluginBase.php b/core/modules/views/src/Plugin/views/sort/SortPluginBase.php index cf036fc810f..db421f30508 100644 --- a/core/modules/views/src/Plugin/views/sort/SortPluginBase.php +++ b/core/modules/views/src/Plugin/views/sort/SortPluginBase.php @@ -49,6 +49,7 @@ protected function defineOptions() { $options['expose'] = [ 'contains' => [ 'label' => ['default' => ''], + 'identifier' => ['default' => ''], ], ]; return $options; @@ -208,7 +209,46 @@ public function buildExposeForm(&$form, FormStateInterface $form_state) { '#required' => TRUE, '#size' => 40, '#weight' => -1, - ]; + ]; + + $form['expose']['identifier'] = [ + '#type' => 'textfield', + '#default_value' => $this->options['expose']['identifier'], + '#title' => $this->t('Sort identifier'), + '#required' => TRUE, + '#size' => 40, + '#description' => $this->t('This will appear in the URL after the ? to identify this sort. Cannot be blank. Only letters, digits and the dot ("."), hyphen ("-"), underscore ("_"), and tilde ("~") characters are allowed.'), + ]; + } + + /** + * Validate the options form. + */ + public function validateExposeForm($form, FormStateInterface $form_state) { + $identifier = $form_state->getValue(['options', 'expose', 'identifier']); + if (!preg_match('/^[a-zA-z][a-zA-Z0-9_~.\-]*$/', $identifier)) { + $form_state->setErrorByName('expose][identifier', $this->t('This identifier has illegal characters.')); + return; + } + + // Validate that the identifier is unique within the sort handlers. The + // DisplayPluginInterface::isIdentifierUnique() cannot be used as the method + // checks if an identifier is unique across all handlers, identifiers being + // used as query string parameter keys. But the sort identifiers are used as + // query string parameter values and they cannot collide with other type of + // handler identifier, so it's legit to have the same sort and filter + // identifiers. + // @see \Drupal\views\Plugin\views\display\DisplayPluginInterface::isIdentifierUnique() + foreach ($this->view->display_handler->getHandlers('sort') as $key => $handler) { + if ($handler->canExpose() && $handler->isExposed()) { + if ($form_state->get('id') !== $key && isset($handler->options['expose']['identifier']) && $identifier === $handler->options['expose']['identifier']) { + $form_state->setErrorByName('expose][identifier', $this->t('This identifier is already used by %label sort handler.', [ + '%label' => $handler->adminLabel(TRUE), + ])); + return; + } + } + } } /** @@ -226,6 +266,7 @@ public static function trustedCallbacks() { public function defaultExposeOptions() { $this->options['expose'] = [ 'label' => $this->definition['title'], + 'identifier' => $this->options['id'], ]; } diff --git a/core/modules/views/src/ViewsConfigUpdater.php b/core/modules/views/src/ViewsConfigUpdater.php index 88442d46ddc..fdb2b603aad 100644 --- a/core/modules/views/src/ViewsConfigUpdater.php +++ b/core/modules/views/src/ViewsConfigUpdater.php @@ -138,6 +138,9 @@ public function updateAll(ViewEntityInterface $view) { if ($this->processMultivalueBaseFieldHandler($handler, $handler_type, $key, $display_id, $view)) { $changed = TRUE; } + if ($this->processSortIdentifierUpdateHandler($handler, $handler_type)) { + $changed = TRUE; + } return $changed; }); } @@ -477,4 +480,38 @@ protected function mapOperatorFromSingleToMultiple($single_operator) { } } + /** + * Updates the sort handlers by adding default sort identifiers. + * + * @param \Drupal\views\ViewEntityInterface $view + * The View to update. + * + * @return bool + * Whether the view was updated. + */ + public function needsSortIdentifierUpdate(ViewEntityInterface $view): bool { + return $this->processDisplayHandlers($view, TRUE, function (array &$handler, string $handler_type): bool { + return $this->processSortIdentifierUpdateHandler($handler, $handler_type); + }); + } + + /** + * Processes sort handlers by adding the sort identifier. + * + * @param array $handler + * A display handler. + * @param string $handler_type + * The handler type. + * + * @return bool + * Whether the handler was updated. + */ + protected function processSortIdentifierUpdateHandler(array &$handler, string $handler_type): bool { + if ($handler_type === 'sort' && !isset($handler['expose']['identifier'])) { + $handler['expose']['identifier'] = $handler['id']; + return TRUE; + } + return FALSE; + } + } diff --git a/core/modules/views/tests/src/Functional/Plugin/ExposedFormTest.php b/core/modules/views/tests/src/Functional/Plugin/ExposedFormTest.php index 647edcf6b29..72b1f45b717 100644 --- a/core/modules/views/tests/src/Functional/Plugin/ExposedFormTest.php +++ b/core/modules/views/tests/src/Functional/Plugin/ExposedFormTest.php @@ -335,18 +335,24 @@ public function testExposedSortAndItemsPerPage() { $this->assertCacheContexts($contexts); $this->assertIds(range(40, 16, 1)); - // Change the label to something with special characters. $view = Views::getView('test_exposed_form_sort_items_per_page'); $view->setDisplay(); $sorts = $view->display_handler->getOption('sorts'); + // Change the label to something with special characters. $sorts['id']['expose']['label'] = $expected_label = ""; + // Use a custom identifier. + $sorts['id']['expose']['identifier'] = $identifier = $this->randomMachineName() . '-_.~'; $view->display_handler->setOption('sorts', $sorts); $view->save(); + // Test label escaping. $this->drupalGet('test_exposed_form_sort_items_per_page'); $options = $this->assertSession()->selectExists('edit-sort-by')->findAll('css', 'option'); $this->assertCount(1, $options); - $this->assertSession()->optionExists('edit-sort-by', $expected_label); + // Check option existence by option label. + $this->assertSession()->optionExists('Sort by', $expected_label); + // Check option existence by option value. + $this->assertSession()->optionExists('Sort by', $identifier); $escape_1 = Html::escape($expected_label); $escape_2 = Html::escape($escape_1); // Make sure we see the single-escaped string in the raw output. @@ -355,6 +361,13 @@ public function testExposedSortAndItemsPerPage() { $this->assertNoRaw($escape_2); // And not the raw label, either. $this->assertNoRaw($expected_label); + + // Check that the custom identifier is used in the URL query string. + $this->drupalPostForm(NULL, ['sort_order' => 'DESC'], 'Apply'); + $this->assertCacheContexts($contexts); + $this->assertIds(range(50, 41)); + $url = $this->getSession()->getCurrentUrl(); + $this->assertStringContainsString('sort_by=' . urlencode($identifier), $url); } /** diff --git a/core/modules/views/tests/src/Functional/Update/ViewsSortIdentifiersUpdateTest.php b/core/modules/views/tests/src/Functional/Update/ViewsSortIdentifiersUpdateTest.php new file mode 100644 index 00000000000..ea774b7a0d8 --- /dev/null +++ b/core/modules/views/tests/src/Functional/Update/ViewsSortIdentifiersUpdateTest.php @@ -0,0 +1,44 @@ +databaseDumpFiles = [ + __DIR__ . '/../../../../../system/tests/fixtures/update/drupal-8.8.0.bare.standard.php.gz', + ]; + } + + /** + * Tests views_post_update_sort_identifier(). + * + * @see views_post_update_sort_identifier() + */ + public function testSortIdentifierPostUpdate(): void { + $config_factory = \Drupal::configFactory(); + $view = $config_factory->get('views.view.comments_recent'); + $trail = 'display.default.display_options.sorts.created'; + $this->assertArrayNotHasKey('identifier', $view->get("{$trail}.expose")); + + $this->runUpdates(); + + $view = $config_factory->get('views.view.comments_recent'); + $sort_handler = $view->get($trail); + $this->assertSame($sort_handler['id'], $sort_handler['expose']['identifier']); + } + +} diff --git a/core/modules/views/tests/src/Kernel/Plugin/DisplayKernelTest.php b/core/modules/views/tests/src/Kernel/Plugin/DisplayKernelTest.php index a2eb682d4cd..9397d130b5a 100644 --- a/core/modules/views/tests/src/Kernel/Plugin/DisplayKernelTest.php +++ b/core/modules/views/tests/src/Kernel/Plugin/DisplayKernelTest.php @@ -130,7 +130,10 @@ public function testisIdentifierUnique() { 'table' => 'views_test_data', 'plugin_id' => 'standard', 'order' => 'asc', - 'expose' => ['label' => 'id'], + 'expose' => [ + 'label' => 'Id', + 'identifier' => 'name', + ], 'exposed' => TRUE, ], ]; @@ -156,10 +159,16 @@ public function testisIdentifierUnique() { ]; $view->display_handler->setOption('sorts', $sorts); $view->display_handler->setOption('filters', $filters); - $view->save(); $this->assertTrue($view->display_handler->isIdentifierUnique('some_id', 'some_id')); $this->assertFalse($view->display_handler->isIdentifierUnique('some_id', 'id')); + + // Check that an exposed filter is able to use the same identifier as an + // exposed sort. + $sorts['name']['expose']['identifier'] = 'id'; + $view->display_handler->handlers = []; + $view->display_handler->setOption('sorts', $sorts); + $this->assertTrue($view->display_handler->isIdentifierUnique('id', 'id')); } } diff --git a/core/modules/views/views.post_update.php b/core/modules/views/views.post_update.php index d7ae26d7bcc..01a9b12bd0b 100644 --- a/core/modules/views/views.post_update.php +++ b/core/modules/views/views.post_update.php @@ -6,6 +6,7 @@ */ use Drupal\Core\Config\Entity\ConfigEntityUpdater; +use Drupal\views\ViewEntityInterface; use Drupal\views\ViewsConfigUpdater; /** @@ -53,6 +54,7 @@ function views_post_update_configuration_entity_relationships() { } /** +<<<<<<< HEAD * Rename the setting for showing the default display to 'default_display'. */ function views_post_update_rename_default_display_setting() { @@ -68,3 +70,14 @@ function views_post_update_rename_default_display_setting() { function views_post_update_remove_sorting_global_text_field() { // Empty post-update hook. } + +/** + * Add the identifier option to all sort handler configurations. + */ +function views_post_update_sort_identifier(?array &$sandbox = NULL): void { + /** @var \Drupal\views\ViewsConfigUpdater $view_config_updater */ + $view_config_updater = \Drupal::classResolver(ViewsConfigUpdater::class); + \Drupal::classResolver(ConfigEntityUpdater::class)->update($sandbox, 'view', function (ViewEntityInterface $view) use ($view_config_updater): bool { + return $view_config_updater->needsSortIdentifierUpdate($view); + }); +} diff --git a/core/modules/views_ui/css/views_ui.admin.theme.css b/core/modules/views_ui/css/views_ui.admin.theme.css index 060afc91eee..857672ab102 100644 --- a/core/modules/views_ui/css/views_ui.admin.theme.css +++ b/core/modules/views_ui/css/views_ui.admin.theme.css @@ -682,6 +682,7 @@ td.group-title { } .form-item-options-expose-required, .form-item-options-expose-label, +.form-item-options-expose-identifier, .form-item-options-expose-description { margin-top: 6px; margin-bottom: 6px; @@ -689,6 +690,7 @@ td.group-title { } [dir="rtl"] .form-item-options-expose-required, [dir="rtl"] .form-item-options-expose-label, +[dir="rtl"] .form-item-options-expose-identifier, [dir="rtl"] .form-item-options-expose-description { margin-right: 18px; margin-left: 0; diff --git a/core/modules/views_ui/tests/src/Functional/ExposedFormUITest.php b/core/modules/views_ui/tests/src/Functional/ExposedFormUITest.php index 873125b952e..d093aef8564 100644 --- a/core/modules/views_ui/tests/src/Functional/ExposedFormUITest.php +++ b/core/modules/views_ui/tests/src/Functional/ExposedFormUITest.php @@ -105,6 +105,7 @@ public function testExposedAdminUi() { $this->drupalGet('admin/structure/views/nojs/handler/test_exposed_admin_ui/default/sort/created'); $this->helperButtonHasLabel('edit-options-expose-button-button', 'Expose sort'); $this->assertSession()->fieldNotExists('edit-options-expose-label'); + $this->assertSession()->fieldNotExists('Sort identifier'); // Un-expose the filter. $this->drupalGet('admin/structure/views/nojs/handler/test_exposed_admin_ui/default/filter/type'); @@ -123,6 +124,7 @@ public function testExposedAdminUi() { // Check the label of the expose button. $this->helperButtonHasLabel('edit-options-expose-button-button', 'Hide sort'); $this->assertSession()->fieldValueEquals('edit-options-expose-label', 'Authored on'); + $this->assertSession()->fieldValueEquals('Sort identifier', 'created'); // Test adding a new exposed sort criteria. $view_id = $this->randomView()['id']; @@ -135,15 +137,42 @@ public function testExposedAdminUi() { $this->submitForm([], 'Expose sort'); $this->assertSession()->fieldValueEquals('options[order]', 'DESC'); $this->assertSession()->fieldValueEquals('options[expose][label]', 'Authored on'); - // Change the label and save the view. - $edit = ['options[expose][label]' => $this->randomString()]; + $this->assertSession()->fieldValueEquals('Sort identifier', 'created'); + + // Change the label and try with an empty identifier. + $edit = [ + 'options[expose][label]' => $this->randomString(), + 'options[expose][identifier]' => '', + ]; + $this->submitForm($edit, 'Apply'); + $this->assertSession()->pageTextContains('Sort identifier field is required.'); + + // Try with an invalid identifier. + $edit['options[expose][identifier]'] = 'abc&! ###08.'; + $this->submitForm($edit, 'Apply'); + $this->assertSession()->pageTextContains('This identifier has illegal characters.'); + + // Use a valid identifier. + $edit['options[expose][identifier]'] = $this->randomMachineName() . '_-~.'; $this->submitForm($edit, 'Apply'); $this->submitForm([], 'Save'); + // Check that the values were saved. $display = View::load($view_id)->getDisplay('default'); $this->assertTrue($display['display_options']['sorts']['created']['exposed']); - $this->assertEquals(['label' => $edit['options[expose][label]']], $display['display_options']['sorts']['created']['expose']); - $this->assertEquals('DESC', $display['display_options']['sorts']['created']['order']); + $this->assertSame([ + 'label' => $edit['options[expose][label]'], + 'identifier' => $edit['options[expose][identifier]'], + ], $display['display_options']['sorts']['created']['expose']); + $this->assertSame('DESC', $display['display_options']['sorts']['created']['order']); + + // Test the identifier uniqueness. + $this->drupalGet("admin/structure/views/nojs/handler/{$view_id}/default/sort/created_1"); + $this->submitForm([], 'Expose sort'); + $this->submitForm([ + 'options[expose][identifier]' => $edit['options[expose][identifier]'], + ], 'Apply'); + $this->assertSession()->pageTextContains('This identifier is already used by Content: Authored on sort handler.'); } /** diff --git a/core/profiles/demo_umami/config/install/views.view.articles_aside.yml b/core/profiles/demo_umami/config/install/views.view.articles_aside.yml index 7a9f37d8bb5..3daad576e37 100644 --- a/core/profiles/demo_umami/config/install/views.view.articles_aside.yml +++ b/core/profiles/demo_umami/config/install/views.view.articles_aside.yml @@ -189,6 +189,7 @@ display: exposed: false expose: label: '' + identifier: created granularity: second nid: id: nid @@ -201,6 +202,7 @@ display: exposed: false expose: label: '' + identifier: nid entity_type: node entity_field: nid plugin_id: standard diff --git a/core/profiles/demo_umami/config/install/views.view.featured_articles.yml b/core/profiles/demo_umami/config/install/views.view.featured_articles.yml index e643082cd3a..b027dc06174 100644 --- a/core/profiles/demo_umami/config/install/views.view.featured_articles.yml +++ b/core/profiles/demo_umami/config/install/views.view.featured_articles.yml @@ -202,6 +202,7 @@ display: exposed: false expose: label: '' + identifier: created granularity: second nid: id: nid @@ -214,6 +215,7 @@ display: exposed: false expose: label: '' + identifier: nid entity_type: node entity_field: nid plugin_id: standard diff --git a/core/profiles/demo_umami/config/install/views.view.frontpage.yml b/core/profiles/demo_umami/config/install/views.view.frontpage.yml index af7dd1167c0..e779f062b47 100644 --- a/core/profiles/demo_umami/config/install/views.view.frontpage.yml +++ b/core/profiles/demo_umami/config/install/views.view.frontpage.yml @@ -229,6 +229,7 @@ display: admin_label: '' expose: label: '' + identifier: sticky exposed: false field: sticky group_type: group @@ -251,6 +252,7 @@ display: exposed: false expose: label: '' + identifier: created granularity: second entity_type: node entity_field: created @@ -265,6 +267,7 @@ display: exposed: false expose: label: '' + identifier: nid entity_type: node entity_field: nid plugin_id: standard diff --git a/core/profiles/demo_umami/config/install/views.view.promoted_items.yml b/core/profiles/demo_umami/config/install/views.view.promoted_items.yml index 2dbaf939619..f575a3b3408 100644 --- a/core/profiles/demo_umami/config/install/views.view.promoted_items.yml +++ b/core/profiles/demo_umami/config/install/views.view.promoted_items.yml @@ -220,6 +220,7 @@ display: exposed: false expose: label: '' + identifier: created granularity: second title: 'Promoted Items Double' header: { } diff --git a/core/profiles/demo_umami/config/install/views.view.recipe_collections.yml b/core/profiles/demo_umami/config/install/views.view.recipe_collections.yml index 1952fc3c417..eaf887484dd 100644 --- a/core/profiles/demo_umami/config/install/views.view.recipe_collections.yml +++ b/core/profiles/demo_umami/config/install/views.view.recipe_collections.yml @@ -178,6 +178,7 @@ display: exposed: false expose: label: '' + identifier: name entity_type: taxonomy_term entity_field: name plugin_id: standard diff --git a/core/profiles/demo_umami/config/install/views.view.recipes.yml b/core/profiles/demo_umami/config/install/views.view.recipes.yml index e3cdb98cb1c..75e8ede20d2 100644 --- a/core/profiles/demo_umami/config/install/views.view.recipes.yml +++ b/core/profiles/demo_umami/config/install/views.view.recipes.yml @@ -202,6 +202,7 @@ display: exposed: false expose: label: '' + identifier: created granularity: second nid: id: nid @@ -214,6 +215,7 @@ display: exposed: false expose: label: '' + identifier: nid entity_type: node entity_field: nid plugin_id: standard diff --git a/core/profiles/demo_umami/config/install/views.view.taxonomy_term.yml b/core/profiles/demo_umami/config/install/views.view.taxonomy_term.yml index 79b65de101d..334da5707c4 100644 --- a/core/profiles/demo_umami/config/install/views.view.taxonomy_term.yml +++ b/core/profiles/demo_umami/config/install/views.view.taxonomy_term.yml @@ -77,6 +77,7 @@ display: exposed: false expose: label: '' + identifier: sticky created: id: created table: taxonomy_index @@ -89,6 +90,7 @@ display: exposed: false expose: label: '' + identifier: created granularity: second arguments: tid: diff --git a/core/profiles/demo_umami/config/optional/views.view.media.yml b/core/profiles/demo_umami/config/optional/views.view.media.yml index 17518dc84a5..133f33443a0 100644 --- a/core/profiles/demo_umami/config/optional/views.view.media.yml +++ b/core/profiles/demo_umami/config/optional/views.view.media.yml @@ -845,6 +845,7 @@ display: exposed: false expose: label: '' + identifier: created granularity: second title: Media header: { } diff --git a/core/themes/claro/css/components/views-ui.css b/core/themes/claro/css/components/views-ui.css index 56fda12d7f4..6ce881042d1 100644 --- a/core/themes/claro/css/components/views-ui.css +++ b/core/themes/claro/css/components/views-ui.css @@ -127,12 +127,14 @@ details.fieldset-no-legend { .form-item-options-expose-required, .form-item-options-expose-label, +.form-item-options-expose-identifier, .form-item-options-expose-description { margin-left: 1.5em; /* LTR */ } [dir="rtl"] .form-item-options-expose-required, [dir="rtl"] .form-item-options-expose-label, +[dir="rtl"] .form-item-options-expose-identifier, [dir="rtl"] .form-item-options-expose-description { margin-right: 1.5em; margin-left: 0; @@ -144,6 +146,7 @@ details.fieldset-no-legend { .views-admin-dependent .form-item .form-item, .form-item-options-expose-required, .form-item-options-expose-label, +.form-item-options-expose-identifier, .form-item-options-expose-description { margin-top: 0.375rem; margin-bottom: 0.375rem; diff --git a/core/themes/claro/css/components/views-ui.pcss.css b/core/themes/claro/css/components/views-ui.pcss.css index 84709902fe7..8efcbf9c147 100644 --- a/core/themes/claro/css/components/views-ui.pcss.css +++ b/core/themes/claro/css/components/views-ui.pcss.css @@ -110,11 +110,13 @@ details.fieldset-no-legend { */ .form-item-options-expose-required, .form-item-options-expose-label, +.form-item-options-expose-identifier, .form-item-options-expose-description { margin-left: 1.5em; /* LTR */ } [dir="rtl"] .form-item-options-expose-required, [dir="rtl"] .form-item-options-expose-label, +[dir="rtl"] .form-item-options-expose-identifier, [dir="rtl"] .form-item-options-expose-description { margin-right: 1.5em; margin-left: 0; @@ -126,6 +128,7 @@ details.fieldset-no-legend { .views-admin-dependent .form-item .form-item, .form-item-options-expose-required, .form-item-options-expose-label, +.form-item-options-expose-identifier, .form-item-options-expose-description { margin-top: 6px; margin-bottom: 6px; diff --git a/core/themes/claro/css/theme/views_ui.admin.theme.css b/core/themes/claro/css/theme/views_ui.admin.theme.css index b3f21bb4e18..25133ce2a20 100644 --- a/core/themes/claro/css/theme/views_ui.admin.theme.css +++ b/core/themes/claro/css/theme/views_ui.admin.theme.css @@ -663,6 +663,7 @@ td.group-title { .form-item-options-expose-required, .form-item-options-expose-label, +.form-item-options-expose-identifier, .form-item-options-expose-description { margin-top: 0.375rem; margin-bottom: 0.375rem; @@ -671,6 +672,7 @@ td.group-title { [dir="rtl"] .form-item-options-expose-required, [dir="rtl"] .form-item-options-expose-label, +[dir="rtl"] .form-item-options-expose-identifier, [dir="rtl"] .form-item-options-expose-description { margin-right: 1.125rem; margin-left: 0; diff --git a/core/themes/claro/css/theme/views_ui.admin.theme.pcss.css b/core/themes/claro/css/theme/views_ui.admin.theme.pcss.css index 3b25581b811..00ef0258214 100644 --- a/core/themes/claro/css/theme/views_ui.admin.theme.pcss.css +++ b/core/themes/claro/css/theme/views_ui.admin.theme.pcss.css @@ -546,6 +546,7 @@ td.group-title { } .form-item-options-expose-required, .form-item-options-expose-label, +.form-item-options-expose-identifier, .form-item-options-expose-description { margin-top: 6px; margin-bottom: 6px; @@ -553,6 +554,7 @@ td.group-title { } [dir="rtl"] .form-item-options-expose-required, [dir="rtl"] .form-item-options-expose-label, +[dir="rtl"] .form-item-options-expose-identifier, [dir="rtl"] .form-item-options-expose-description { margin-right: 18px; margin-left: 0; diff --git a/core/themes/seven/css/components/views-ui.css b/core/themes/seven/css/components/views-ui.css index bb79f4d1619..7e85d57a993 100644 --- a/core/themes/seven/css/components/views-ui.css +++ b/core/themes/seven/css/components/views-ui.css @@ -64,11 +64,13 @@ details.fieldset-no-legend { */ .form-item-options-expose-required, .form-item-options-expose-label, +.form-item-options-expose-identifier, .form-item-options-expose-description { margin-left: 1.5em; /* LTR */ } [dir="rtl"] .form-item-options-expose-required, [dir="rtl"] .form-item-options-expose-label, +[dir="rtl"] .form-item-options-expose-identifier, [dir="rtl"] .form-item-options-expose-description { margin-right: 1.5em; margin-left: 0; @@ -80,6 +82,7 @@ details.fieldset-no-legend { .views-admin-dependent .form-item .form-item, .form-item-options-expose-required, .form-item-options-expose-label, +.form-item-options-expose-identifier, .form-item-options-expose-description { margin-top: 6px; margin-bottom: 6px; diff --git a/core/themes/stable/css/views_ui/views_ui.admin.theme.css b/core/themes/stable/css/views_ui/views_ui.admin.theme.css index 32de3f97c5f..139e86df903 100644 --- a/core/themes/stable/css/views_ui/views_ui.admin.theme.css +++ b/core/themes/stable/css/views_ui/views_ui.admin.theme.css @@ -682,6 +682,7 @@ td.group-title { } .form-item-options-expose-required, .form-item-options-expose-label, +.form-item-options-expose-identifier, .form-item-options-expose-description { margin-top: 6px; margin-bottom: 6px; @@ -689,6 +690,7 @@ td.group-title { } [dir="rtl"] .form-item-options-expose-required, [dir="rtl"] .form-item-options-expose-label, +[dir="rtl"] .form-item-options-expose-identifier, [dir="rtl"] .form-item-options-expose-description { margin-right: 18px; margin-left: 0; diff --git a/core/themes/stable9/css/views_ui/views_ui.admin.theme.css b/core/themes/stable9/css/views_ui/views_ui.admin.theme.css index dd988dfe99d..f81c28427bf 100644 --- a/core/themes/stable9/css/views_ui/views_ui.admin.theme.css +++ b/core/themes/stable9/css/views_ui/views_ui.admin.theme.css @@ -682,6 +682,7 @@ td.group-title { } .form-item-options-expose-required, .form-item-options-expose-label, +.form-item-options-expose-identifier, .form-item-options-expose-description { margin-top: 6px; margin-bottom: 6px; @@ -689,6 +690,7 @@ td.group-title { } [dir="rtl"] .form-item-options-expose-required, [dir="rtl"] .form-item-options-expose-label, +[dir="rtl"] .form-item-options-expose-identifier, [dir="rtl"] .form-item-options-expose-description { margin-right: 18px; margin-left: 0; -- GitLab From 426c20105e285ac1b0048377dff4ef60f4bef4aa Mon Sep 17 00:00:00 2001 From: Claudiu Cristea Date: Tue, 24 Nov 2020 11:02:22 +0200 Subject: [PATCH 2/4] Rename 'identifier' with 'field_identifier'. --- .../config/optional/views.view.comment.yml | 2 +- .../optional/views.view.comments_recent.yml | 4 +- .../config/optional/views.view.watchdog.yml | 2 +- .../config/optional/views.view.media.yml | 2 +- .../install/views.view.media_library.yml | 6 +-- .../config/optional/views.view.archive.yml | 2 +- .../optional/views.view.content_recent.yml | 2 +- .../config/optional/views.view.frontpage.yml | 4 +- .../optional/views.view.taxonomy_term.yml | 4 +- .../optional/views.view.user_admin_people.yml | 2 +- .../config/optional/views.view.who_s_new.yml | 2 +- .../optional/views.view.who_s_online.yml | 2 +- .../config/schema/views.data_types.schema.yml | 4 +- .../views/display/DisplayPluginBase.php | 7 ---- .../exposed_form/ExposedFormPluginBase.php | 8 ++-- .../src/Plugin/views/sort/SortPluginBase.php | 40 ++++++++++--------- core/modules/views/src/ViewsConfigUpdater.php | 14 +++---- .../src/Functional/Plugin/ExposedFormTest.php | 12 +++--- .../Update/ViewsSortIdentifiersUpdateTest.php | 6 +-- .../src/Kernel/Plugin/DisplayKernelTest.php | 4 +- core/modules/views/views.post_update.php | 2 +- .../views_ui/css/views_ui.admin.theme.css | 4 +- .../src/Functional/ExposedFormUITest.php | 18 ++++----- .../install/views.view.articles_aside.yml | 4 +- .../install/views.view.featured_articles.yml | 4 +- .../config/install/views.view.frontpage.yml | 6 +-- .../install/views.view.promoted_items.yml | 2 +- .../install/views.view.recipe_collections.yml | 2 +- .../config/install/views.view.recipes.yml | 4 +- .../install/views.view.taxonomy_term.yml | 4 +- .../config/optional/views.view.media.yml | 2 +- core/themes/claro/css/components/views-ui.css | 6 +-- .../claro/css/components/views-ui.pcss.css | 6 +-- .../claro/css/theme/views_ui.admin.theme.css | 4 +- .../css/theme/views_ui.admin.theme.pcss.css | 4 +- core/themes/seven/css/components/views-ui.css | 6 +-- .../css/views_ui/views_ui.admin.theme.css | 4 +- .../css/views_ui/views_ui.admin.theme.css | 4 +- 38 files changed, 105 insertions(+), 110 deletions(-) diff --git a/core/modules/comment/config/optional/views.view.comment.yml b/core/modules/comment/config/optional/views.view.comment.yml index 147b32b587c..45d566636fe 100644 --- a/core/modules/comment/config/optional/views.view.comment.yml +++ b/core/modules/comment/config/optional/views.view.comment.yml @@ -806,7 +806,7 @@ display: exposed: false expose: label: '' - identifier: changed + field_identifier: changed granularity: second entity_type: comment entity_field: changed diff --git a/core/modules/comment/config/optional/views.view.comments_recent.yml b/core/modules/comment/config/optional/views.view.comments_recent.yml index 4382f13b084..587040dad86 100644 --- a/core/modules/comment/config/optional/views.view.comments_recent.yml +++ b/core/modules/comment/config/optional/views.view.comments_recent.yml @@ -206,7 +206,7 @@ display: exposed: false expose: label: '' - identifier: created + field_identifier: created plugin_id: date entity_type: comment entity_field: created @@ -221,7 +221,7 @@ display: exposed: false expose: label: '' - identifier: cid + field_identifier: cid plugin_id: field entity_type: comment entity_field: cid diff --git a/core/modules/dblog/config/optional/views.view.watchdog.yml b/core/modules/dblog/config/optional/views.view.watchdog.yml index 1bffe2c9c02..b3da477847b 100644 --- a/core/modules/dblog/config/optional/views.view.watchdog.yml +++ b/core/modules/dblog/config/optional/views.view.watchdog.yml @@ -647,7 +647,7 @@ display: exposed: false expose: label: '' - identifier: wid + field_identifier: wid plugin_id: standard title: 'Recent log messages' header: { } diff --git a/core/modules/media/config/optional/views.view.media.yml b/core/modules/media/config/optional/views.view.media.yml index 133f33443a0..df4df46c72c 100644 --- a/core/modules/media/config/optional/views.view.media.yml +++ b/core/modules/media/config/optional/views.view.media.yml @@ -845,7 +845,7 @@ display: exposed: false expose: label: '' - identifier: created + field_identifier: created granularity: second title: Media header: { } diff --git a/core/modules/media_library/config/install/views.view.media_library.yml b/core/modules/media_library/config/install/views.view.media_library.yml index e48b104dbb7..1bd04639ef3 100644 --- a/core/modules/media_library/config/install/views.view.media_library.yml +++ b/core/modules/media_library/config/install/views.view.media_library.yml @@ -418,7 +418,7 @@ display: exposed: true expose: label: 'Newest first' - identifier: created + field_identifier: created granularity: second entity_type: media entity_field: created @@ -434,7 +434,7 @@ display: exposed: true expose: label: 'Name (A-Z)' - identifier: name + field_identifier: name entity_type: media entity_field: name plugin_id: standard @@ -449,7 +449,7 @@ display: exposed: true expose: label: 'Name (Z-A)' - identifier: name_1 + field_identifier: name_1 entity_type: media entity_field: name plugin_id: standard diff --git a/core/modules/node/config/optional/views.view.archive.yml b/core/modules/node/config/optional/views.view.archive.yml index f020fdef098..9ac4c063b22 100644 --- a/core/modules/node/config/optional/views.view.archive.yml +++ b/core/modules/node/config/optional/views.view.archive.yml @@ -77,7 +77,7 @@ display: exposed: false expose: label: '' - identifier: created + field_identifier: created granularity: second entity_type: node entity_field: created diff --git a/core/modules/node/config/optional/views.view.content_recent.yml b/core/modules/node/config/optional/views.view.content_recent.yml index 5e0c0cd7a59..ec80480d247 100644 --- a/core/modules/node/config/optional/views.view.content_recent.yml +++ b/core/modules/node/config/optional/views.view.content_recent.yml @@ -254,7 +254,7 @@ display: exposed: false expose: label: '' - identifier: changed + field_identifier: changed granularity: second entity_type: node entity_field: changed diff --git a/core/modules/node/config/optional/views.view.frontpage.yml b/core/modules/node/config/optional/views.view.frontpage.yml index c4fed0c3243..3b0bd894129 100644 --- a/core/modules/node/config/optional/views.view.frontpage.yml +++ b/core/modules/node/config/optional/views.view.frontpage.yml @@ -203,7 +203,7 @@ display: admin_label: '' expose: label: '' - identifier: sticky + field_identifier: sticky exposed: false field: sticky group_type: group @@ -226,7 +226,7 @@ display: exposed: false expose: label: '' - identifier: created + field_identifier: created granularity: second entity_type: node entity_field: created diff --git a/core/modules/taxonomy/config/optional/views.view.taxonomy_term.yml b/core/modules/taxonomy/config/optional/views.view.taxonomy_term.yml index b5806afcf8f..0fa147dda59 100644 --- a/core/modules/taxonomy/config/optional/views.view.taxonomy_term.yml +++ b/core/modules/taxonomy/config/optional/views.view.taxonomy_term.yml @@ -77,7 +77,7 @@ display: exposed: false expose: label: '' - identifier: sticky + field_identifier: sticky created: id: created table: taxonomy_index @@ -90,7 +90,7 @@ display: exposed: false expose: label: '' - identifier: created + field_identifier: created granularity: second arguments: tid: diff --git a/core/modules/user/config/optional/views.view.user_admin_people.yml b/core/modules/user/config/optional/views.view.user_admin_people.yml index c028c2a7339..7a6de5a7f3a 100644 --- a/core/modules/user/config/optional/views.view.user_admin_people.yml +++ b/core/modules/user/config/optional/views.view.user_admin_people.yml @@ -846,7 +846,7 @@ display: exposed: false expose: label: '' - identifier: created + field_identifier: created granularity: second plugin_id: date entity_type: user diff --git a/core/modules/user/config/optional/views.view.who_s_new.yml b/core/modules/user/config/optional/views.view.who_s_new.yml index 8656af39087..1054052d3aa 100644 --- a/core/modules/user/config/optional/views.view.who_s_new.yml +++ b/core/modules/user/config/optional/views.view.who_s_new.yml @@ -156,7 +156,7 @@ display: exposed: false expose: label: '' - identifier: created + field_identifier: created granularity: second plugin_id: date entity_type: user diff --git a/core/modules/user/config/optional/views.view.who_s_online.yml b/core/modules/user/config/optional/views.view.who_s_online.yml index 329fece4df0..2b40ccf43d7 100644 --- a/core/modules/user/config/optional/views.view.who_s_online.yml +++ b/core/modules/user/config/optional/views.view.who_s_online.yml @@ -165,7 +165,7 @@ display: exposed: false expose: label: '' - identifier: access + field_identifier: access granularity: second plugin_id: date entity_type: user diff --git a/core/modules/views/config/schema/views.data_types.schema.yml b/core/modules/views/config/schema/views.data_types.schema.yml index 791a8531312..f9f73973f2d 100644 --- a/core/modules/views/config/schema/views.data_types.schema.yml +++ b/core/modules/views/config/schema/views.data_types.schema.yml @@ -281,9 +281,9 @@ views_sort_expose: label: type: label label: 'Label' - identifier: + field_identifier: type: string - label: 'Identifier' + label: 'Field identifier' views_area: type: views_handler diff --git a/core/modules/views/src/Plugin/views/display/DisplayPluginBase.php b/core/modules/views/src/Plugin/views/display/DisplayPluginBase.php index 1ebbf854d8f..0d89fb724be 100644 --- a/core/modules/views/src/Plugin/views/display/DisplayPluginBase.php +++ b/core/modules/views/src/Plugin/views/display/DisplayPluginBase.php @@ -2559,13 +2559,6 @@ public function newDisplay() { */ public function isIdentifierUnique($id, $identifier) { foreach (ViewExecutable::getHandlerTypes() as $type => $info) { - if ($type === 'sort') { - // The exposed sort identifier is the value of 'sort_by' query string - // parameter and cannot collide with $identifier as the later is used as - // query string parameter key. - continue; - } - foreach ($this->getHandlers($type) as $key => $handler) { if ($handler->canExpose() && $handler->isExposed()) { if ($handler->isAGroup()) { diff --git a/core/modules/views/src/Plugin/views/exposed_form/ExposedFormPluginBase.php b/core/modules/views/src/Plugin/views/exposed_form/ExposedFormPluginBase.php index 71a352afc04..75daffccb05 100644 --- a/core/modules/views/src/Plugin/views/exposed_form/ExposedFormPluginBase.php +++ b/core/modules/views/src/Plugin/views/exposed_form/ExposedFormPluginBase.php @@ -162,7 +162,7 @@ public function query() { if (!$sort->isExposed()) { $sort->query(); } - elseif (!empty($sort->options['expose']['identifier']) && $sort->options['expose']['identifier'] === $sort_by) { + elseif (!empty($sort->options['expose']['field_identifier']) && $sort->options['expose']['field_identifier'] === $sort_by) { if (isset($exposed_data['sort_order']) && in_array($exposed_data['sort_order'], ['ASC', 'DESC'], TRUE)) { $sort->options['order'] = $exposed_data['sort_order']; } @@ -205,9 +205,9 @@ public function exposedFormAlter(&$form, FormStateInterface $form_state) { $exposed_sorts = []; $exposed_sorts_options = []; foreach ($this->view->sort as $id => $handler) { - if ($handler->canExpose() && $handler->isExposed() && !empty($handler->options['expose']['identifier'])) { - $exposed_sorts[$handler->options['expose']['identifier']] = $id; - $exposed_sorts_options[$handler->options['expose']['identifier']] = $handler->options['expose']['label']; + if ($handler->canExpose() && $handler->isExposed() && !empty($handler->options['expose']['field_identifier'])) { + $exposed_sorts[$handler->options['expose']['field_identifier']] = $id; + $exposed_sorts_options[$handler->options['expose']['field_identifier']] = $handler->options['expose']['label']; } } diff --git a/core/modules/views/src/Plugin/views/sort/SortPluginBase.php b/core/modules/views/src/Plugin/views/sort/SortPluginBase.php index db421f30508..fc0039d8757 100644 --- a/core/modules/views/src/Plugin/views/sort/SortPluginBase.php +++ b/core/modules/views/src/Plugin/views/sort/SortPluginBase.php @@ -49,7 +49,7 @@ protected function defineOptions() { $options['expose'] = [ 'contains' => [ 'label' => ['default' => ''], - 'identifier' => ['default' => ''], + 'field_identifier' => ['default' => ''], ], ]; return $options; @@ -211,13 +211,13 @@ public function buildExposeForm(&$form, FormStateInterface $form_state) { '#weight' => -1, ]; - $form['expose']['identifier'] = [ + $form['expose']['field_identifier'] = [ '#type' => 'textfield', - '#default_value' => $this->options['expose']['identifier'], - '#title' => $this->t('Sort identifier'), + '#default_value' => $this->options['expose']['field_identifier'], + '#title' => $this->t('Sort field identifier'), '#required' => TRUE, '#size' => 40, - '#description' => $this->t('This will appear in the URL after the ? to identify this sort. Cannot be blank. Only letters, digits and the dot ("."), hyphen ("-"), underscore ("_"), and tilde ("~") characters are allowed.'), + '#description' => $this->t("This will appear in the URL after the ?, as value of 'sort_by' parameter, to identify this sort field. Cannot be blank. Only letters, digits and the dot ('.'), hyphen ('-'), underscore ('_'), and tilde ('~') characters are allowed."), ]; } @@ -225,24 +225,28 @@ public function buildExposeForm(&$form, FormStateInterface $form_state) { * Validate the options form. */ public function validateExposeForm($form, FormStateInterface $form_state) { - $identifier = $form_state->getValue(['options', 'expose', 'identifier']); - if (!preg_match('/^[a-zA-z][a-zA-Z0-9_~.\-]*$/', $identifier)) { - $form_state->setErrorByName('expose][identifier', $this->t('This identifier has illegal characters.')); + $field_identifier = $form_state->getValue([ + 'options', + 'expose', + 'field_identifier', + ]); + if (!preg_match('/^[a-zA-z][a-zA-Z0-9_~.\-]*$/', $field_identifier)) { + $form_state->setErrorByName('expose][field_identifier', $this->t('This identifier has illegal characters.')); return; } - // Validate that the identifier is unique within the sort handlers. The - // DisplayPluginInterface::isIdentifierUnique() cannot be used as the method - // checks if an identifier is unique across all handlers, identifiers being - // used as query string parameter keys. But the sort identifiers are used as - // query string parameter values and they cannot collide with other type of - // handler identifier, so it's legit to have the same sort and filter - // identifiers. + // Validate that the sort field identifier is unique within the sort + // handlers. Note that the sort field identifier is different that other + // identifiers because is used, in URLs, as query string value of 'sort_by' + // parameter, while the others are used as query string parameter keys. For + // this reason it's legit to have a sort field identifier same as an exposed + // filter identifier. This prevents us to validate the uniqueness of this + // identifier by using DisplayPluginInterface::isIdentifierUnique(). // @see \Drupal\views\Plugin\views\display\DisplayPluginInterface::isIdentifierUnique() foreach ($this->view->display_handler->getHandlers('sort') as $key => $handler) { if ($handler->canExpose() && $handler->isExposed()) { - if ($form_state->get('id') !== $key && isset($handler->options['expose']['identifier']) && $identifier === $handler->options['expose']['identifier']) { - $form_state->setErrorByName('expose][identifier', $this->t('This identifier is already used by %label sort handler.', [ + if ($form_state->get('id') !== $key && isset($handler->options['expose']['field_identifier']) && $field_identifier === $handler->options['expose']['field_identifier']) { + $form_state->setErrorByName('expose][field_identifier', $this->t('This identifier is already used by %label sort handler.', [ '%label' => $handler->adminLabel(TRUE), ])); return; @@ -266,7 +270,7 @@ public static function trustedCallbacks() { public function defaultExposeOptions() { $this->options['expose'] = [ 'label' => $this->definition['title'], - 'identifier' => $this->options['id'], + 'field_identifier' => $this->options['id'], ]; } diff --git a/core/modules/views/src/ViewsConfigUpdater.php b/core/modules/views/src/ViewsConfigUpdater.php index fdb2b603aad..dfb89e338ad 100644 --- a/core/modules/views/src/ViewsConfigUpdater.php +++ b/core/modules/views/src/ViewsConfigUpdater.php @@ -138,7 +138,7 @@ public function updateAll(ViewEntityInterface $view) { if ($this->processMultivalueBaseFieldHandler($handler, $handler_type, $key, $display_id, $view)) { $changed = TRUE; } - if ($this->processSortIdentifierUpdateHandler($handler, $handler_type)) { + if ($this->processSortFieldIdentifierUpdateHandler($handler, $handler_type)) { $changed = TRUE; } return $changed; @@ -481,7 +481,7 @@ protected function mapOperatorFromSingleToMultiple($single_operator) { } /** - * Updates the sort handlers by adding default sort identifiers. + * Updates the sort handlers by adding default sort field identifiers. * * @param \Drupal\views\ViewEntityInterface $view * The View to update. @@ -489,9 +489,9 @@ protected function mapOperatorFromSingleToMultiple($single_operator) { * @return bool * Whether the view was updated. */ - public function needsSortIdentifierUpdate(ViewEntityInterface $view): bool { + public function needsSortFieldIdentifierUpdate(ViewEntityInterface $view): bool { return $this->processDisplayHandlers($view, TRUE, function (array &$handler, string $handler_type): bool { - return $this->processSortIdentifierUpdateHandler($handler, $handler_type); + return $this->processSortFieldIdentifierUpdateHandler($handler, $handler_type); }); } @@ -506,9 +506,9 @@ public function needsSortIdentifierUpdate(ViewEntityInterface $view): bool { * @return bool * Whether the handler was updated. */ - protected function processSortIdentifierUpdateHandler(array &$handler, string $handler_type): bool { - if ($handler_type === 'sort' && !isset($handler['expose']['identifier'])) { - $handler['expose']['identifier'] = $handler['id']; + protected function processSortFieldIdentifierUpdateHandler(array &$handler, string $handler_type): bool { + if ($handler_type === 'sort' && !isset($handler['expose']['field_identifier'])) { + $handler['expose']['field_identifier'] = $handler['id']; return TRUE; } return FALSE; diff --git a/core/modules/views/tests/src/Functional/Plugin/ExposedFormTest.php b/core/modules/views/tests/src/Functional/Plugin/ExposedFormTest.php index 72b1f45b717..fcb2bc6b058 100644 --- a/core/modules/views/tests/src/Functional/Plugin/ExposedFormTest.php +++ b/core/modules/views/tests/src/Functional/Plugin/ExposedFormTest.php @@ -340,8 +340,8 @@ public function testExposedSortAndItemsPerPage() { $sorts = $view->display_handler->getOption('sorts'); // Change the label to something with special characters. $sorts['id']['expose']['label'] = $expected_label = ""; - // Use a custom identifier. - $sorts['id']['expose']['identifier'] = $identifier = $this->randomMachineName() . '-_.~'; + // Use a custom sort field identifier. + $sorts['id']['expose']['field_identifier'] = $field_identifier = $this->randomMachineName() . '-_.~'; $view->display_handler->setOption('sorts', $sorts); $view->save(); @@ -352,7 +352,7 @@ public function testExposedSortAndItemsPerPage() { // Check option existence by option label. $this->assertSession()->optionExists('Sort by', $expected_label); // Check option existence by option value. - $this->assertSession()->optionExists('Sort by', $identifier); + $this->assertSession()->optionExists('Sort by', $field_identifier); $escape_1 = Html::escape($expected_label); $escape_2 = Html::escape($escape_1); // Make sure we see the single-escaped string in the raw output. @@ -362,12 +362,12 @@ public function testExposedSortAndItemsPerPage() { // And not the raw label, either. $this->assertNoRaw($expected_label); - // Check that the custom identifier is used in the URL query string. - $this->drupalPostForm(NULL, ['sort_order' => 'DESC'], 'Apply'); + // Check that the custom field identifier is used in the URL query string. + $this->submitForm(['sort_order' => 'DESC'], 'Apply'); $this->assertCacheContexts($contexts); $this->assertIds(range(50, 41)); $url = $this->getSession()->getCurrentUrl(); - $this->assertStringContainsString('sort_by=' . urlencode($identifier), $url); + $this->assertStringContainsString('sort_by=' . urlencode($field_identifier), $url); } /** diff --git a/core/modules/views/tests/src/Functional/Update/ViewsSortIdentifiersUpdateTest.php b/core/modules/views/tests/src/Functional/Update/ViewsSortIdentifiersUpdateTest.php index ea774b7a0d8..e7b0cbdcd30 100644 --- a/core/modules/views/tests/src/Functional/Update/ViewsSortIdentifiersUpdateTest.php +++ b/core/modules/views/tests/src/Functional/Update/ViewsSortIdentifiersUpdateTest.php @@ -1,7 +1,5 @@ get('views.view.comments_recent'); $trail = 'display.default.display_options.sorts.created'; - $this->assertArrayNotHasKey('identifier', $view->get("{$trail}.expose")); + $this->assertArrayNotHasKey('field_identifier', $view->get("{$trail}.expose")); $this->runUpdates(); $view = $config_factory->get('views.view.comments_recent'); $sort_handler = $view->get($trail); - $this->assertSame($sort_handler['id'], $sort_handler['expose']['identifier']); + $this->assertSame($sort_handler['id'], $sort_handler['expose']['field_identifier']); } } diff --git a/core/modules/views/tests/src/Kernel/Plugin/DisplayKernelTest.php b/core/modules/views/tests/src/Kernel/Plugin/DisplayKernelTest.php index 9397d130b5a..1fe28612385 100644 --- a/core/modules/views/tests/src/Kernel/Plugin/DisplayKernelTest.php +++ b/core/modules/views/tests/src/Kernel/Plugin/DisplayKernelTest.php @@ -132,7 +132,7 @@ public function testisIdentifierUnique() { 'order' => 'asc', 'expose' => [ 'label' => 'Id', - 'identifier' => 'name', + 'field_identifier' => 'name', ], 'exposed' => TRUE, ], @@ -165,7 +165,7 @@ public function testisIdentifierUnique() { // Check that an exposed filter is able to use the same identifier as an // exposed sort. - $sorts['name']['expose']['identifier'] = 'id'; + $sorts['name']['expose']['field_identifier'] = 'id'; $view->display_handler->handlers = []; $view->display_handler->setOption('sorts', $sorts); $this->assertTrue($view->display_handler->isIdentifierUnique('id', 'id')); diff --git a/core/modules/views/views.post_update.php b/core/modules/views/views.post_update.php index 01a9b12bd0b..e19f26fc673 100644 --- a/core/modules/views/views.post_update.php +++ b/core/modules/views/views.post_update.php @@ -78,6 +78,6 @@ function views_post_update_sort_identifier(?array &$sandbox = NULL): void { /** @var \Drupal\views\ViewsConfigUpdater $view_config_updater */ $view_config_updater = \Drupal::classResolver(ViewsConfigUpdater::class); \Drupal::classResolver(ConfigEntityUpdater::class)->update($sandbox, 'view', function (ViewEntityInterface $view) use ($view_config_updater): bool { - return $view_config_updater->needsSortIdentifierUpdate($view); + return $view_config_updater->needsSortFieldIdentifierUpdate($view); }); } diff --git a/core/modules/views_ui/css/views_ui.admin.theme.css b/core/modules/views_ui/css/views_ui.admin.theme.css index 857672ab102..565132721c6 100644 --- a/core/modules/views_ui/css/views_ui.admin.theme.css +++ b/core/modules/views_ui/css/views_ui.admin.theme.css @@ -682,7 +682,7 @@ td.group-title { } .form-item-options-expose-required, .form-item-options-expose-label, -.form-item-options-expose-identifier, +.form-item-options-expose-field-identifier, .form-item-options-expose-description { margin-top: 6px; margin-bottom: 6px; @@ -690,7 +690,7 @@ td.group-title { } [dir="rtl"] .form-item-options-expose-required, [dir="rtl"] .form-item-options-expose-label, -[dir="rtl"] .form-item-options-expose-identifier, +[dir="rtl"] .form-item-options-expose-field-identifier, [dir="rtl"] .form-item-options-expose-description { margin-right: 18px; margin-left: 0; diff --git a/core/modules/views_ui/tests/src/Functional/ExposedFormUITest.php b/core/modules/views_ui/tests/src/Functional/ExposedFormUITest.php index d093aef8564..62b8ba89da1 100644 --- a/core/modules/views_ui/tests/src/Functional/ExposedFormUITest.php +++ b/core/modules/views_ui/tests/src/Functional/ExposedFormUITest.php @@ -105,7 +105,7 @@ public function testExposedAdminUi() { $this->drupalGet('admin/structure/views/nojs/handler/test_exposed_admin_ui/default/sort/created'); $this->helperButtonHasLabel('edit-options-expose-button-button', 'Expose sort'); $this->assertSession()->fieldNotExists('edit-options-expose-label'); - $this->assertSession()->fieldNotExists('Sort identifier'); + $this->assertSession()->fieldNotExists('Sort field identifier'); // Un-expose the filter. $this->drupalGet('admin/structure/views/nojs/handler/test_exposed_admin_ui/default/filter/type'); @@ -124,7 +124,7 @@ public function testExposedAdminUi() { // Check the label of the expose button. $this->helperButtonHasLabel('edit-options-expose-button-button', 'Hide sort'); $this->assertSession()->fieldValueEquals('edit-options-expose-label', 'Authored on'); - $this->assertSession()->fieldValueEquals('Sort identifier', 'created'); + $this->assertSession()->fieldValueEquals('Sort field identifier', 'created'); // Test adding a new exposed sort criteria. $view_id = $this->randomView()['id']; @@ -137,23 +137,23 @@ public function testExposedAdminUi() { $this->submitForm([], 'Expose sort'); $this->assertSession()->fieldValueEquals('options[order]', 'DESC'); $this->assertSession()->fieldValueEquals('options[expose][label]', 'Authored on'); - $this->assertSession()->fieldValueEquals('Sort identifier', 'created'); + $this->assertSession()->fieldValueEquals('Sort field identifier', 'created'); // Change the label and try with an empty identifier. $edit = [ 'options[expose][label]' => $this->randomString(), - 'options[expose][identifier]' => '', + 'options[expose][field_identifier]' => '', ]; $this->submitForm($edit, 'Apply'); - $this->assertSession()->pageTextContains('Sort identifier field is required.'); + $this->assertSession()->pageTextContains('Sort field identifier field is required.'); // Try with an invalid identifier. - $edit['options[expose][identifier]'] = 'abc&! ###08.'; + $edit['options[expose][field_identifier]'] = 'abc&! ###08.'; $this->submitForm($edit, 'Apply'); $this->assertSession()->pageTextContains('This identifier has illegal characters.'); // Use a valid identifier. - $edit['options[expose][identifier]'] = $this->randomMachineName() . '_-~.'; + $edit['options[expose][field_identifier]'] = $this->randomMachineName() . '_-~.'; $this->submitForm($edit, 'Apply'); $this->submitForm([], 'Save'); @@ -162,7 +162,7 @@ public function testExposedAdminUi() { $this->assertTrue($display['display_options']['sorts']['created']['exposed']); $this->assertSame([ 'label' => $edit['options[expose][label]'], - 'identifier' => $edit['options[expose][identifier]'], + 'field_identifier' => $edit['options[expose][field_identifier]'], ], $display['display_options']['sorts']['created']['expose']); $this->assertSame('DESC', $display['display_options']['sorts']['created']['order']); @@ -170,7 +170,7 @@ public function testExposedAdminUi() { $this->drupalGet("admin/structure/views/nojs/handler/{$view_id}/default/sort/created_1"); $this->submitForm([], 'Expose sort'); $this->submitForm([ - 'options[expose][identifier]' => $edit['options[expose][identifier]'], + 'options[expose][field_identifier]' => $edit['options[expose][field_identifier]'], ], 'Apply'); $this->assertSession()->pageTextContains('This identifier is already used by Content: Authored on sort handler.'); } diff --git a/core/profiles/demo_umami/config/install/views.view.articles_aside.yml b/core/profiles/demo_umami/config/install/views.view.articles_aside.yml index 3daad576e37..b1821bc6e23 100644 --- a/core/profiles/demo_umami/config/install/views.view.articles_aside.yml +++ b/core/profiles/demo_umami/config/install/views.view.articles_aside.yml @@ -189,7 +189,7 @@ display: exposed: false expose: label: '' - identifier: created + field_identifier: created granularity: second nid: id: nid @@ -202,7 +202,7 @@ display: exposed: false expose: label: '' - identifier: nid + field_identifier: nid entity_type: node entity_field: nid plugin_id: standard diff --git a/core/profiles/demo_umami/config/install/views.view.featured_articles.yml b/core/profiles/demo_umami/config/install/views.view.featured_articles.yml index b027dc06174..a547a78769f 100644 --- a/core/profiles/demo_umami/config/install/views.view.featured_articles.yml +++ b/core/profiles/demo_umami/config/install/views.view.featured_articles.yml @@ -202,7 +202,7 @@ display: exposed: false expose: label: '' - identifier: created + field_identifier: created granularity: second nid: id: nid @@ -215,7 +215,7 @@ display: exposed: false expose: label: '' - identifier: nid + field_identifier: nid entity_type: node entity_field: nid plugin_id: standard diff --git a/core/profiles/demo_umami/config/install/views.view.frontpage.yml b/core/profiles/demo_umami/config/install/views.view.frontpage.yml index e779f062b47..f614159078d 100644 --- a/core/profiles/demo_umami/config/install/views.view.frontpage.yml +++ b/core/profiles/demo_umami/config/install/views.view.frontpage.yml @@ -229,7 +229,7 @@ display: admin_label: '' expose: label: '' - identifier: sticky + field_identifier: sticky exposed: false field: sticky group_type: group @@ -252,7 +252,7 @@ display: exposed: false expose: label: '' - identifier: created + field_identifier: created granularity: second entity_type: node entity_field: created @@ -267,7 +267,7 @@ display: exposed: false expose: label: '' - identifier: nid + field_identifier: nid entity_type: node entity_field: nid plugin_id: standard diff --git a/core/profiles/demo_umami/config/install/views.view.promoted_items.yml b/core/profiles/demo_umami/config/install/views.view.promoted_items.yml index f575a3b3408..7d1262f62c2 100644 --- a/core/profiles/demo_umami/config/install/views.view.promoted_items.yml +++ b/core/profiles/demo_umami/config/install/views.view.promoted_items.yml @@ -220,7 +220,7 @@ display: exposed: false expose: label: '' - identifier: created + field_identifier: created granularity: second title: 'Promoted Items Double' header: { } diff --git a/core/profiles/demo_umami/config/install/views.view.recipe_collections.yml b/core/profiles/demo_umami/config/install/views.view.recipe_collections.yml index eaf887484dd..9113af5ef79 100644 --- a/core/profiles/demo_umami/config/install/views.view.recipe_collections.yml +++ b/core/profiles/demo_umami/config/install/views.view.recipe_collections.yml @@ -178,7 +178,7 @@ display: exposed: false expose: label: '' - identifier: name + field_identifier: name entity_type: taxonomy_term entity_field: name plugin_id: standard diff --git a/core/profiles/demo_umami/config/install/views.view.recipes.yml b/core/profiles/demo_umami/config/install/views.view.recipes.yml index 75e8ede20d2..80af602c9a0 100644 --- a/core/profiles/demo_umami/config/install/views.view.recipes.yml +++ b/core/profiles/demo_umami/config/install/views.view.recipes.yml @@ -202,7 +202,7 @@ display: exposed: false expose: label: '' - identifier: created + field_identifier: created granularity: second nid: id: nid @@ -215,7 +215,7 @@ display: exposed: false expose: label: '' - identifier: nid + field_identifier: nid entity_type: node entity_field: nid plugin_id: standard diff --git a/core/profiles/demo_umami/config/install/views.view.taxonomy_term.yml b/core/profiles/demo_umami/config/install/views.view.taxonomy_term.yml index 334da5707c4..7b8355922d3 100644 --- a/core/profiles/demo_umami/config/install/views.view.taxonomy_term.yml +++ b/core/profiles/demo_umami/config/install/views.view.taxonomy_term.yml @@ -77,7 +77,7 @@ display: exposed: false expose: label: '' - identifier: sticky + field_identifier: sticky created: id: created table: taxonomy_index @@ -90,7 +90,7 @@ display: exposed: false expose: label: '' - identifier: created + field_identifier: created granularity: second arguments: tid: diff --git a/core/profiles/demo_umami/config/optional/views.view.media.yml b/core/profiles/demo_umami/config/optional/views.view.media.yml index 133f33443a0..df4df46c72c 100644 --- a/core/profiles/demo_umami/config/optional/views.view.media.yml +++ b/core/profiles/demo_umami/config/optional/views.view.media.yml @@ -845,7 +845,7 @@ display: exposed: false expose: label: '' - identifier: created + field_identifier: created granularity: second title: Media header: { } diff --git a/core/themes/claro/css/components/views-ui.css b/core/themes/claro/css/components/views-ui.css index 6ce881042d1..6fc7a173758 100644 --- a/core/themes/claro/css/components/views-ui.css +++ b/core/themes/claro/css/components/views-ui.css @@ -127,14 +127,14 @@ details.fieldset-no-legend { .form-item-options-expose-required, .form-item-options-expose-label, -.form-item-options-expose-identifier, +.form-item-options-expose-field-identifier, .form-item-options-expose-description { margin-left: 1.5em; /* LTR */ } [dir="rtl"] .form-item-options-expose-required, [dir="rtl"] .form-item-options-expose-label, -[dir="rtl"] .form-item-options-expose-identifier, +[dir="rtl"] .form-item-options-expose-field-identifier, [dir="rtl"] .form-item-options-expose-description { margin-right: 1.5em; margin-left: 0; @@ -146,7 +146,7 @@ details.fieldset-no-legend { .views-admin-dependent .form-item .form-item, .form-item-options-expose-required, .form-item-options-expose-label, -.form-item-options-expose-identifier, +.form-item-options-expose-field-identifier, .form-item-options-expose-description { margin-top: 0.375rem; margin-bottom: 0.375rem; diff --git a/core/themes/claro/css/components/views-ui.pcss.css b/core/themes/claro/css/components/views-ui.pcss.css index 8efcbf9c147..9e8a723ab05 100644 --- a/core/themes/claro/css/components/views-ui.pcss.css +++ b/core/themes/claro/css/components/views-ui.pcss.css @@ -110,13 +110,13 @@ details.fieldset-no-legend { */ .form-item-options-expose-required, .form-item-options-expose-label, -.form-item-options-expose-identifier, +.form-item-options-expose-field-identifier, .form-item-options-expose-description { margin-left: 1.5em; /* LTR */ } [dir="rtl"] .form-item-options-expose-required, [dir="rtl"] .form-item-options-expose-label, -[dir="rtl"] .form-item-options-expose-identifier, +[dir="rtl"] .form-item-options-expose-field-identifier, [dir="rtl"] .form-item-options-expose-description { margin-right: 1.5em; margin-left: 0; @@ -128,7 +128,7 @@ details.fieldset-no-legend { .views-admin-dependent .form-item .form-item, .form-item-options-expose-required, .form-item-options-expose-label, -.form-item-options-expose-identifier, +.form-item-options-expose-field-identifier, .form-item-options-expose-description { margin-top: 6px; margin-bottom: 6px; diff --git a/core/themes/claro/css/theme/views_ui.admin.theme.css b/core/themes/claro/css/theme/views_ui.admin.theme.css index 25133ce2a20..76fd7b7de66 100644 --- a/core/themes/claro/css/theme/views_ui.admin.theme.css +++ b/core/themes/claro/css/theme/views_ui.admin.theme.css @@ -663,7 +663,7 @@ td.group-title { .form-item-options-expose-required, .form-item-options-expose-label, -.form-item-options-expose-identifier, +.form-item-options-expose-field-identifier, .form-item-options-expose-description { margin-top: 0.375rem; margin-bottom: 0.375rem; @@ -672,7 +672,7 @@ td.group-title { [dir="rtl"] .form-item-options-expose-required, [dir="rtl"] .form-item-options-expose-label, -[dir="rtl"] .form-item-options-expose-identifier, +[dir="rtl"] .form-item-options-expose-field-identifier, [dir="rtl"] .form-item-options-expose-description { margin-right: 1.125rem; margin-left: 0; diff --git a/core/themes/claro/css/theme/views_ui.admin.theme.pcss.css b/core/themes/claro/css/theme/views_ui.admin.theme.pcss.css index 00ef0258214..3c0ff632501 100644 --- a/core/themes/claro/css/theme/views_ui.admin.theme.pcss.css +++ b/core/themes/claro/css/theme/views_ui.admin.theme.pcss.css @@ -546,7 +546,7 @@ td.group-title { } .form-item-options-expose-required, .form-item-options-expose-label, -.form-item-options-expose-identifier, +.form-item-options-expose-field-identifier, .form-item-options-expose-description { margin-top: 6px; margin-bottom: 6px; @@ -554,7 +554,7 @@ td.group-title { } [dir="rtl"] .form-item-options-expose-required, [dir="rtl"] .form-item-options-expose-label, -[dir="rtl"] .form-item-options-expose-identifier, +[dir="rtl"] .form-item-options-expose-field-identifier, [dir="rtl"] .form-item-options-expose-description { margin-right: 18px; margin-left: 0; diff --git a/core/themes/seven/css/components/views-ui.css b/core/themes/seven/css/components/views-ui.css index 7e85d57a993..912c8257b4c 100644 --- a/core/themes/seven/css/components/views-ui.css +++ b/core/themes/seven/css/components/views-ui.css @@ -64,13 +64,13 @@ details.fieldset-no-legend { */ .form-item-options-expose-required, .form-item-options-expose-label, -.form-item-options-expose-identifier, +.form-item-options-expose-field-identifier, .form-item-options-expose-description { margin-left: 1.5em; /* LTR */ } [dir="rtl"] .form-item-options-expose-required, [dir="rtl"] .form-item-options-expose-label, -[dir="rtl"] .form-item-options-expose-identifier, +[dir="rtl"] .form-item-options-expose-field-identifier, [dir="rtl"] .form-item-options-expose-description { margin-right: 1.5em; margin-left: 0; @@ -82,7 +82,7 @@ details.fieldset-no-legend { .views-admin-dependent .form-item .form-item, .form-item-options-expose-required, .form-item-options-expose-label, -.form-item-options-expose-identifier, +.form-item-options-expose-field-identifier, .form-item-options-expose-description { margin-top: 6px; margin-bottom: 6px; diff --git a/core/themes/stable/css/views_ui/views_ui.admin.theme.css b/core/themes/stable/css/views_ui/views_ui.admin.theme.css index 139e86df903..39fc644fea4 100644 --- a/core/themes/stable/css/views_ui/views_ui.admin.theme.css +++ b/core/themes/stable/css/views_ui/views_ui.admin.theme.css @@ -682,7 +682,7 @@ td.group-title { } .form-item-options-expose-required, .form-item-options-expose-label, -.form-item-options-expose-identifier, +.form-item-options-expose-field-identifier, .form-item-options-expose-description { margin-top: 6px; margin-bottom: 6px; @@ -690,7 +690,7 @@ td.group-title { } [dir="rtl"] .form-item-options-expose-required, [dir="rtl"] .form-item-options-expose-label, -[dir="rtl"] .form-item-options-expose-identifier, +[dir="rtl"] .form-item-options-expose-field-identifier, [dir="rtl"] .form-item-options-expose-description { margin-right: 18px; margin-left: 0; diff --git a/core/themes/stable9/css/views_ui/views_ui.admin.theme.css b/core/themes/stable9/css/views_ui/views_ui.admin.theme.css index f81c28427bf..344e974012c 100644 --- a/core/themes/stable9/css/views_ui/views_ui.admin.theme.css +++ b/core/themes/stable9/css/views_ui/views_ui.admin.theme.css @@ -682,7 +682,7 @@ td.group-title { } .form-item-options-expose-required, .form-item-options-expose-label, -.form-item-options-expose-identifier, +.form-item-options-expose-field-identifier, .form-item-options-expose-description { margin-top: 6px; margin-bottom: 6px; @@ -690,7 +690,7 @@ td.group-title { } [dir="rtl"] .form-item-options-expose-required, [dir="rtl"] .form-item-options-expose-label, -[dir="rtl"] .form-item-options-expose-identifier, +[dir="rtl"] .form-item-options-expose-field-identifier, [dir="rtl"] .form-item-options-expose-description { margin-right: 18px; margin-left: 0; -- GitLab From 2066239c5c557634504cdb11fe8521c71356710d Mon Sep 17 00:00:00 2001 From: Claudiu Cristea Date: Thu, 15 Apr 2021 16:01:11 +0300 Subject: [PATCH 3/4] Improve docs. --- .../views/src/Plugin/views/sort/SortPluginBase.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/core/modules/views/src/Plugin/views/sort/SortPluginBase.php b/core/modules/views/src/Plugin/views/sort/SortPluginBase.php index fc0039d8757..fcac77e013e 100644 --- a/core/modules/views/src/Plugin/views/sort/SortPluginBase.php +++ b/core/modules/views/src/Plugin/views/sort/SortPluginBase.php @@ -237,11 +237,11 @@ public function validateExposeForm($form, FormStateInterface $form_state) { // Validate that the sort field identifier is unique within the sort // handlers. Note that the sort field identifier is different that other - // identifiers because is used, in URLs, as query string value of 'sort_by' - // parameter, while the others are used as query string parameter keys. For - // this reason it's legit to have a sort field identifier same as an exposed - // filter identifier. This prevents us to validate the uniqueness of this - // identifier by using DisplayPluginInterface::isIdentifierUnique(). + // identifiers because it is used as a query string value of the 'sort_by' + // parameter, while the others are used as query string parameter keys. + // Therefore we can have a sort field identifier be the same as an exposed + // filter identifier. This prevents us from using + // DisplayPluginInterface::isIdentifierUnique() to test for uniqueness. // @see \Drupal\views\Plugin\views\display\DisplayPluginInterface::isIdentifierUnique() foreach ($this->view->display_handler->getHandlers('sort') as $key => $handler) { if ($handler->canExpose() && $handler->isExposed()) { -- GitLab From eaa43b0c10c6fff8595d72d23c0f40a028bf0a71 Mon Sep 17 00:00:00 2001 From: Claudiu Cristea Date: Thu, 15 Apr 2021 16:07:19 +0300 Subject: [PATCH 4/4] Cleanup leftover. --- core/modules/views/views.post_update.php | 1 - 1 file changed, 1 deletion(-) diff --git a/core/modules/views/views.post_update.php b/core/modules/views/views.post_update.php index e19f26fc673..fbdcff9db4d 100644 --- a/core/modules/views/views.post_update.php +++ b/core/modules/views/views.post_update.php @@ -54,7 +54,6 @@ function views_post_update_configuration_entity_relationships() { } /** -<<<<<<< HEAD * Rename the setting for showing the default display to 'default_display'. */ function views_post_update_rename_default_display_setting() { -- GitLab