diff -u b/modules/redirect_404/redirect_404.views.inc b/modules/redirect_404/redirect_404.views.inc --- b/modules/redirect_404/redirect_404.views.inc +++ b/modules/redirect_404/redirect_404.views.inc @@ -29,12 +29,6 @@ 'filter' => [ 'id' => 'string', ], - 'argument' => [ - 'id' => 'string', - ], - 'sort' => [ - 'id' => 'standard', - ], ]; $data['redirect_404']['langcode'] = [ @@ -43,16 +37,10 @@ 'field' => [ 'id' => 'redirect_404_langcode', ], - 'argument' => [ - 'id' => 'string', - ], 'filter' => [ 'id' => 'in_operator', 'options callback' => '_redirect_404_get_langcodes', ], - 'sort' => [ - 'id' => 'standard', - ], ]; $data['redirect_404']['count'] = [ @@ -62,15 +50,9 @@ 'id' => 'numeric', 'click sortable' => TRUE, ], - 'argument' => [ - 'id' => 'numeric', - ], 'filter' => [ 'id' => 'numeric', ], - 'sort' => [ - 'id' => 'standard', - ], ]; $data['redirect_404']['timestamp'] = [ @@ -80,15 +62,9 @@ 'id' => 'date', 'click sortable' => TRUE, ], - 'argument' => [ - 'id' => 'date', - ], 'filter' => [ 'id' => 'date', ], - 'sort' => [ - 'id' => 'date', - ], ]; $data['redirect_404']['resolved'] = [ @@ -102,9 +78,6 @@ 'label' => t('Resolved'), 'use_equal' => TRUE, ], - 'sort' => [ - 'id' => 'standard', - ], ]; $data['redirect_404']['add_redirect'] = [ diff -u b/modules/redirect_404/src/Tests/Fix404RedirectUILanguageTest.php b/modules/redirect_404/src/Tests/Fix404RedirectUILanguageTest.php --- b/modules/redirect_404/src/Tests/Fix404RedirectUILanguageTest.php +++ b/modules/redirect_404/src/Tests/Fix404RedirectUILanguageTest.php @@ -81,6 +81,8 @@ $this->drupalGet('admin/config/search/redirect/404'); $this->assertText('testing'); $this->assertText('French'); + // Check the language view filter. + $this->assertOption('edit-langcode', 'fr'); $this->clickLink(t('Add redirect')); // Check if we generate correct Add redirect url and if the form is @@ -90,7 +92,7 @@ 'query' => [ 'source' => 'testing', 'language' => 'fr', - 'destination' => $destination, + 'destination' => ltrim($destination, '/'), ] ]; $this->assertUrl('admin/config/search/redirect/add', $edit); @@ -135,12 +137,68 @@ $this->assertUrl('admin/config/search/redirect/404'); $this->assertText('No 404 pages without redirects found.'); + // Check the redirect overview. $this->drupalGet('admin/config/search/redirect'); - $this->assertText('testing'); $this->assertText('German'); // Check if the redirect works as expected. $this->assertRedirect('de/testing', 'de/node', 'HTTP/1.1 301 Moved Permanently'); + + // Visit multiple non existing pages to test the Redirect 404 View. + $this->drupalGet('testing'); + $this->drupalGet('de/testing'); + $this->drupalGet('admin/config/search/redirect/404'); + $this->assertNoText('French'); + $this->assertText('English'); + $this->assertText('German'); + + // Check the Language view filter. + $this->assertNoOption('edit-langcode', 'fr'); + $this->assertOption('edit-langcode', 'en'); + $this->assertOption('edit-langcode', 'de'); + + // Test the Language view filter. + $this->drupalGet('admin/config/search/redirect/404', ['query' => ['langcode' => 'de']]); + $this->assertNoText('French'); + $this->assertNoText('English'); + $this->assertText('German'); + $this->drupalGet('admin/config/search/redirect/404'); + $this->assertNoText('French'); + $this->assertText('English'); + $this->assertText('German'); + $this->drupalGet('admin/config/search/redirect/404', ['query' => ['langcode' => 'en']]); + $this->assertNoText('French'); + $this->assertText('English'); + $this->assertNoText('German'); + + // Assign a redirect to 'de/testing'. + $this->clickLink('Add redirect'); + $edit = [ + 'query' => [ + 'source' => 'testing', + 'language' => 'en', + 'destination' => ltrim($destination, '/'), + ] + ]; + $this->assertUrl('admin/config/search/redirect/add', $edit); + $this->assertFieldByName('redirect_source[0][path]', 'testing'); + $this->assertOptionSelected('edit-language-0-value', 'en'); + + // Save the redirect. + $edit = ['redirect_redirect[0][uri]' => '/node']; + $this->drupalPostForm(NULL, $edit, t('Save')); + $this->assertUrl('admin/config/search/redirect/404'); + $this->assertNoText('French'); + $this->assertNoText('English'); + $this->assertText('German'); + + // Check the redirect overview. + $this->drupalGet('admin/config/search/redirect'); + $this->assertText('German'); + $this->assertText('English'); + + // Check if the redirect works as expected. + $this->assertRedirect('en/testing', 'en/node', 'HTTP/1.1 301 Moved Permanently'); } } diff -u b/modules/redirect_404/src/Tests/Fix404RedirectUITest.php b/modules/redirect_404/src/Tests/Fix404RedirectUITest.php --- b/modules/redirect_404/src/Tests/Fix404RedirectUITest.php +++ b/modules/redirect_404/src/Tests/Fix404RedirectUITest.php @@ -41,7 +41,7 @@ 'node', 'path', 'dblog', - 'views', + //'views', ]; /** @@ -71,11 +71,11 @@ $this->drupalLogin($this->adminUser); // Visit a non existing page to have the 404 redirect_error entry. - $this->drupalGet('non-existing'); + $this->drupalGet('non-existing0'); // Go to the "fix 404" page and check the listing. $this->drupalGet('admin/config/search/redirect/404'); - $this->assertText('non-existing'); + $this->assertText('non-existing0'); $this->clickLink(t('Add redirect')); // Check if we generate correct Add redirect url and if the form is @@ -83,13 +83,13 @@ $destination = Url::fromUri('base:admin/config/search/redirect/404')->toString(); $edit = [ 'query' => [ - 'source' => 'non-existing', + 'source' => 'non-existing0', 'language' => 'en', - 'destination' => $destination, + 'destination' => ltrim($destination, '/'), ] ]; $this->assertUrl('admin/config/search/redirect/add', $edit); - $this->assertFieldByName('redirect_source[0][path]', 'non-existing'); + $this->assertFieldByName('redirect_source[0][path]', 'non-existing0'); // Save the redirect. $this->drupalPostForm(NULL, ['redirect_redirect[0][uri]' => '/node'], t('Save')); @@ -97,12 +97,12 @@ $this->assertText('No 404 pages without redirects found.'); // Check if the redirect works as expected. - $this->drupalGet('non-existing'); + $this->drupalGet('non-existing0'); $this->assertUrl('node'); // Test removing a redirect assignment and visit again a non existing page. $this->drupalGet('admin/config/search/redirect'); - $this->assertText('non-existing'); + $this->assertText('non-existing0'); $this->clickLink('Delete', 0); $this->drupalPostForm(NULL, [], 'Delete'); @@ -113,9 +113,54 @@ $this->assertText('No 404 pages without redirects found.'); // Visit again the non existing page. - $this->drupalGet('non-existing'); + $this->drupalGet('non-existing0'); $this->drupalGet('admin/config/search/redirect/404'); - $this->assertText('non-existing'); + $this->assertText('non-existing0'); + + // Visit multiple non existing pages to test the Redirect 404 View. + $this->drupalGet('non-existing1'); + $this->drupalGet('non-existing2'); + + $this->drupalGet('admin/config/search/redirect/404'); + $this->assertText('non-existing0'); + $this->assertText('non-existing1'); + $this->assertText('non-existing2'); + + // Test the Path view filter. + $this->drupalGet('admin/config/search/redirect/404', ['query' => ['path' => 'existing1']]); + $this->assertNoText('non-existing0'); + $this->assertText('non-existing1'); + $this->assertNoText('non-existing2'); + $this->drupalGet('admin/config/search/redirect/404'); + $this->assertText('non-existing0'); + $this->assertText('non-existing1'); + $this->assertText('non-existing2'); + $this->drupalGet('admin/config/search/redirect/404', ['query' => ['path' => '2']]); + $this->assertNoText('non-existing0'); + $this->assertNoText('non-existing1'); + $this->assertText('non-existing2'); + + // Assign a redirect to 'non-existing2'. + $this->clickLink('Add redirect'); + $edit = [ + 'query' => [ + 'source' => 'non-existing2', + 'language' => 'en', + 'destination' => ltrim($destination, '/'), + ] + ]; + $this->assertUrl('admin/config/search/redirect/add', $edit); + $this->assertFieldByName('redirect_source[0][path]', 'non-existing2'); + + // Save the redirect. + $this->drupalPostForm(NULL, ['redirect_redirect[0][uri]' => '/node'], t('Save')); + $this->assertUrl('admin/config/search/redirect/404'); + $this->assertText('non-existing0'); + $this->assertText('non-existing1'); + $this->assertNoText('non-existing2'); + + $this->drupalGet('admin/config/search/redirect'); + $this->assertText('non-existing2'); } } only in patch2: unchanged: --- /dev/null +++ b/modules/redirect_404/config/install/views.view.redirect_404.yml @@ -0,0 +1,533 @@ +langcode: en +status: true +dependencies: + module: + - redirect_404 + - user +_core: + default_config_hash: 2rsFUSFEDFsSQI8RcHGdYvhjc_6QzUWv5SNp5ADCopI +id: redirect_404 +label: 'Redirect 404' +module: views +description: '' +tag: '' +base_table: redirect_404 +base_field: '' +core: 8.x +display: + default: + display_plugin: default + id: default + display_title: Master + position: 0 + display_options: + access: + type: perm + options: + perm: 'access site reports' + cache: + type: none + options: { } + query: + type: views_query + options: + disable_sql_rewrite: false + distinct: false + replica: false + query_comment: '' + query_tags: { } + exposed_form: + type: basic + options: + submit_button: Filter + reset_button: true + reset_button_label: Reset + exposed_sorts_label: 'Sort by' + expose_sort_order: true + sort_asc_label: Asc + sort_desc_label: Desc + pager: + type: mini + options: + items_per_page: 10 + offset: 0 + id: 0 + total_pages: null + expose: + items_per_page: false + items_per_page_label: 'Items per page' + items_per_page_options: '5, 10, 25, 50' + items_per_page_options_all: false + items_per_page_options_all_label: '- All -' + offset: false + offset_label: Offset + tags: + previous: ‹‹ + next: ›› + style: + type: table + options: + grouping: { } + row_class: '' + default_row_class: true + override: true + sticky: false + caption: '' + summary: '' + description: '' + columns: + path: path + count: count + timestamp: timestamp + info: + path: + sortable: true + default_sort_order: desc + align: '' + separator: '' + empty_column: false + responsive: '' + count: + sortable: true + default_sort_order: desc + align: '' + separator: '' + empty_column: false + responsive: '' + timestamp: + sortable: true + default_sort_order: desc + align: '' + separator: '' + empty_column: false + responsive: '' + default: count + empty_table: false + row: + type: fields + fields: + path: + table: redirect_404 + field: path + id: path + entity_type: null + entity_field: null + plugin_id: standard + relationship: none + group_type: group + admin_label: '' + label: Path + exclude: false + alter: + alter_text: false + text: '' + make_link: false + path: '' + absolute: false + external: false + replace_spaces: false + path_case: none + trim_whitespace: false + alt: '' + rel: '' + link_class: '' + prefix: '' + suffix: '' + target: '' + nl2br: false + max_length: 0 + word_boundary: true + ellipsis: true + more_link: false + more_link_text: '' + more_link_path: '' + strip_tags: false + trim: false + preserve_tags: '' + html: false + element_type: '' + element_class: '' + element_label_type: '' + element_label_class: '' + element_label_colon: true + element_wrapper_type: '' + element_wrapper_class: '' + element_default_classes: true + empty: '' + hide_empty: false + empty_zero: false + hide_alter_empty: true + count: + id: count + table: redirect_404 + field: count + relationship: none + group_type: group + admin_label: '' + label: Count + exclude: false + alter: + alter_text: false + text: '' + make_link: false + path: '' + absolute: false + external: false + replace_spaces: false + path_case: none + trim_whitespace: false + alt: '' + rel: '' + link_class: '' + prefix: '' + suffix: '' + target: '' + nl2br: false + max_length: 0 + word_boundary: true + ellipsis: true + more_link: false + more_link_text: '' + more_link_path: '' + strip_tags: false + trim: false + preserve_tags: '' + html: false + element_type: '' + element_class: '' + element_label_type: '' + element_label_class: '' + element_label_colon: true + element_wrapper_type: '' + element_wrapper_class: '' + element_default_classes: true + empty: '' + hide_empty: false + empty_zero: false + hide_alter_empty: true +# set_precision: false +# precision: 0 +# decimal: . +# separator: '' +# format_plural: 0 +# format_plural_string: "1\x03@count" +# prefix: '' +# suffix: '' + format: unserialized + key: '' + plugin_id: serialized + timestamp: + id: timestamp + table: redirect_404 + field: timestamp + relationship: none + group_type: group + admin_label: '' + label: 'Last accessed' + exclude: false + alter: + alter_text: false + text: '' + make_link: false + path: '' + absolute: false + external: false + replace_spaces: false + path_case: none + trim_whitespace: false + alt: '' + rel: '' + link_class: '' + prefix: '' + suffix: '' + target: '' + nl2br: false + max_length: 0 + word_boundary: true + ellipsis: true + more_link: false + more_link_text: '' + more_link_path: '' + strip_tags: false + trim: false + preserve_tags: '' + html: false + element_type: '' + element_class: '' + element_label_type: '' + element_label_class: '' + element_label_colon: true + element_wrapper_type: '' + element_wrapper_class: '' + element_default_classes: true + empty: '' + hide_empty: false + empty_zero: false + hide_alter_empty: true + date_format: short + custom_date_format: '' + timezone: '' + plugin_id: date + langcode: + id: langcode + table: redirect_404 + field: langcode + relationship: none + group_type: group + admin_label: '' + label: Language + exclude: false + alter: + alter_text: false + text: '' + make_link: false + path: '' + absolute: false + external: false + replace_spaces: false + path_case: none + trim_whitespace: false + alt: '' + rel: '' + link_class: '' + prefix: '' + suffix: '' + target: '' + nl2br: false + max_length: 0 + word_boundary: true + ellipsis: true + more_link: false + more_link_text: '' + more_link_path: '' + strip_tags: false + trim: false + preserve_tags: '' + html: false + element_type: '' + element_class: '' + element_label_type: '' + element_label_class: '' + element_label_colon: true + element_wrapper_type: '' + element_wrapper_class: '' + element_default_classes: true + empty: '' + hide_empty: false + empty_zero: false + hide_alter_empty: true + plugin_id: standard + add_redirect: + id: add_redirect + table: redirect_404 + field: add_redirect + relationship: none + group_type: group + admin_label: '' + label: Operations + exclude: false + alter: + alter_text: false + text: '' + make_link: false + path: '' + absolute: false + external: false + replace_spaces: false + path_case: none + trim_whitespace: false + alt: '' + rel: '' + link_class: '' + prefix: '' + suffix: '' + target: '' + nl2br: false + max_length: 0 + word_boundary: true + ellipsis: true + more_link: false + more_link_text: '' + more_link_path: '' + strip_tags: false + trim: false + preserve_tags: '' + html: false + element_type: '' + element_class: '' + element_label_type: '' + element_label_class: '' + element_label_colon: true + element_wrapper_type: '' + element_wrapper_class: '' + element_default_classes: true + empty: '' + hide_empty: false + empty_zero: false + hide_alter_empty: true + plugin_id: add_redirect + filters: + path: + id: path + table: redirect_404 + field: path + relationship: none + group_type: group + admin_label: '' + operator: contains + value: '' + group: 1 + exposed: true + expose: + operator_id: path_op + label: Path + description: '' + use_operator: false + operator: path_op + identifier: path + required: false + remember: false + multiple: false + remember_roles: + authenticated: authenticated + anonymous: '0' + administrator: '0' + is_grouped: false + group_info: + label: '' + description: '' + identifier: '' + optional: true + widget: select + multiple: false + remember: false + default_group: All + default_group_multiple: { } + group_items: { } + plugin_id: string + langcode: + id: langcode + table: redirect_404 + field: langcode + relationship: none + group_type: group + admin_label: '' + operator: in + value: { } + group: 1 + exposed: true + expose: + operator_id: langcode_op + label: Language + description: '' + use_operator: false + operator: langcode_op + identifier: langcode + required: false + remember: false + multiple: false + remember_roles: + authenticated: authenticated + anonymous: '0' + administrator: '0' + reduce: false + is_grouped: false + group_info: + label: '' + description: '' + identifier: '' + optional: true + widget: select + multiple: false + remember: false + default_group: All + default_group_multiple: { } + group_items: { } + plugin_id: in_operator + resolved: + id: resolved + table: redirect_404 + field: resolved + relationship: none + group_type: group + admin_label: '' + operator: '=' + value: false + group: 1 + exposed: false + expose: + operator_id: '' + label: Resolved + description: '' + use_operator: false + operator: resolved_op + identifier: resolved + required: false + remember: false + multiple: false + remember_roles: + authenticated: authenticated + anonymous: '0' + administrator: '0' + is_grouped: false + group_info: + label: '' + description: '' + identifier: '' + optional: true + widget: select + multiple: false + remember: false + default_group: All + default_group_multiple: { } + group_items: { } + plugin_id: boolean + sorts: { } + title: 'Fix 404 pages' + header: { } + footer: { } + empty: + area_text_custom: + id: area_text_custom + table: views + field: area_text_custom + relationship: none + group_type: group + admin_label: '' + empty: true + tokenize: false + content: 'No 404 pages without redirects found.' + plugin_id: text_custom + relationships: { } + arguments: { } + display_extenders: { } + filter_groups: + operator: AND + groups: + 1: AND + cache_metadata: + max-age: 0 + contexts: + - 'languages:language_interface' + - url + - url.query_args + - user.permissions + tags: { } + page_1: + display_plugin: page + id: page_1 + display_title: Page + position: 1 + display_options: + display_extenders: { } + path: admin/config/search/redirect/404 + display_description: 'Lists 404 error paths with no redirect assigned yet.' + enabled: true + cache_metadata: + max-age: 0 + contexts: + - 'languages:language_interface' + - url + - url.query_args + - user.permissions + tags: { }