Skip to content
Snippets Groups Projects
Commit f742d155 authored by catch's avatar catch
Browse files

Issue #3396741 by recrit, smustgrave: Content Moderation...

Issue #3396741 by recrit, smustgrave: Content Moderation moderation_state_filter cannot join the entity revision table when the filter uses relationship to the entity revision table
parent 7e2db381
No related branches found
Tags 11-69241
31 merge requests!11131[10.4.x-only-DO-NOT-MERGE]: Issue ##2842525 Ajax attached to Views exposed filter form does not trigger callbacks,!9470[10.3.x-only-DO-NOT-MERGE]: #3331771 Fix file_get_contents(): Passing null to parameter,!8540Issue #3457061: Bootstrap Modal dialog Not closing after 10.3.0 Update,!8528Issue #3456871 by Tim Bozeman: Support NULL services,!8373Issue #3427374 by danflanagan8, Vighneshh: taxonomy_tid ViewsArgumentDefault...,!7526Expose roles in response,!7352Draft: Resolve #3203489 "Set filename as",!6791Issue #3163299: Ajax exposed filters not working for multiple instances of the same Views block placed on one page,!3878Removed unused condition head title for views,!3818Issue #2140179: $entity->original gets stale between updates,!3742Issue #3328429: Create item list field formatter for displaying ordered and unordered lists,!3731Claro: role=button on status report items,!3668Resolve #3347842 "Deprecate the trusted",!3651Issue #3347736: Create new SDC component for Olivero (header-search),!3531Issue #3336994: StringFormatter always displays links to entity even if the user in context does not have access,!3355Issue #3209129: Scrolling problems when adding a block via layout builder,!3154Fixes #2987987 - CSRF token validation broken on routes with optional parameters.,!3133core/modules/system/css/components/hidden.module.css,!2812Issue #3312049: [Followup] Fix Drupal.Commenting.FunctionComment.MissingReturnType returns for NULL,!2794Issue #3100732: Allow specifying `meta` data on JSON:API objects,!2378Issue #2875033: Optimize joins and table selection in SQL entity query implementation,!2334Issue #3228209: Add hasRole() method to AccountInterface,!2062Issue #3246454: Add weekly granularity to views date sort,!1105Issue #3025039: New non translatable field on translatable content throws error,!1073issue #3191727: Focus states on mobile second level navigation items fixed,!10223132456: Fix issue where views instances are emptied before an ajax request is complete,!877Issue #2708101: Default value for link text is not saved,!617Issue #3043725: Provide a Entity Handler for user cancelation,!579Issue #2230909: Simple decimals fail to pass validation,!560Move callback classRemove outside of the loop,!555Issue #3202493
Pipeline #104058 canceled
Pipeline: drupal

#104060

    ...@@ -144,16 +144,17 @@ protected function opSimple() { ...@@ -144,16 +144,17 @@ protected function opSimple() {
    $entity_base_table = $entity_type->getBaseTable(); $entity_base_table = $entity_type->getBaseTable();
    $entity_revision_base_table = $entity_type->isTranslatable() ? $entity_type->getRevisionDataTable() : $entity_type->getRevisionTable(); $entity_revision_base_table = $entity_type->isTranslatable() ? $entity_type->getRevisionDataTable() : $entity_type->getRevisionTable();
    if ($this->table === $entity_revision_base_table) { if ($this->table === $entity_revision_base_table) {
    $entity_revision_base_table_alias = $this->relationship ?: $this->table;
    $configuration = [ $configuration = [
    'table' => $entity_base_table, 'table' => $entity_base_table,
    'field' => $entity_type->getKey('id'), 'field' => $entity_type->getKey('id'),
    'left_table' => $entity_revision_base_table, 'left_table' => $entity_revision_base_table_alias,
    'left_field' => $entity_type->getKey('id'), 'left_field' => $entity_type->getKey('id'),
    'type' => 'INNER', 'type' => 'INNER',
    ]; ];
    $join = Views::pluginManager('join')->createInstance('standard', $configuration); $join = Views::pluginManager('join')->createInstance('standard', $configuration);
    $entity_base_table_alias = $this->query->addRelationship($entity_base_table, $join, $entity_revision_base_table); $entity_base_table_alias = $this->query->addRelationship($entity_base_table, $join, $entity_revision_base_table_alias);
    } }
    $bundle_condition = $this->view->query->getConnection()->condition('AND'); $bundle_condition = $this->view->query->getConnection()->condition('AND');
    ......
    langcode: en
    status: true
    dependencies:
    module:
    - content_moderation
    - user
    id: test_content_moderation_filter_via_revision_relationship
    label: test_content_moderation_filter_via_revision_relationship
    module: views
    description: ''
    tag: ''
    base_table: users_field_data
    base_field: uid
    display:
    default:
    id: default
    display_title: Default
    display_plugin: default
    position: 0
    display_options:
    title: test_content_moderation_filter_via_revision_relationship
    fields:
    name:
    id: name
    table: users_field_data
    field: name
    relationship: none
    group_type: group
    admin_label: ''
    entity_type: user
    entity_field: name
    plugin_id: field
    label: ''
    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: false
    ellipsis: false
    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: false
    element_wrapper_type: ''
    element_wrapper_class: ''
    element_default_classes: true
    empty: ''
    hide_empty: false
    empty_zero: false
    hide_alter_empty: true
    click_sort_column: value
    type: user_name
    settings:
    link_to_entity: false
    group_column: value
    group_columns: { }
    group_rows: true
    delta_limit: 0
    delta_offset: 0
    delta_reversed: false
    delta_first_last: false
    multi_type: separator
    separator: ', '
    field_api_classes: false
    title:
    id: title
    table: node_field_revision
    field: title
    relationship: uid_revision_test
    group_type: group
    admin_label: ''
    entity_type: node
    entity_field: title
    plugin_id: field
    label: ''
    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: false
    element_wrapper_type: ''
    element_wrapper_class: ''
    element_default_classes: true
    empty: ''
    hide_empty: false
    empty_zero: false
    hide_alter_empty: true
    click_sort_column: value
    type: string
    settings:
    link_to_entity: false
    group_column: value
    group_columns: { }
    group_rows: true
    delta_limit: 0
    delta_offset: 0
    delta_reversed: false
    delta_first_last: false
    multi_type: separator
    separator: ', '
    field_api_classes: false
    moderation_state:
    id: moderation_state
    table: node_field_revision
    field: moderation_state
    relationship: uid_revision_test
    group_type: group
    admin_label: ''
    entity_type: node
    plugin_id: moderation_state_field
    label: ''
    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: false
    element_wrapper_type: ''
    element_wrapper_class: ''
    element_default_classes: true
    empty: ''
    hide_empty: false
    empty_zero: false
    hide_alter_empty: true
    click_sort_column: value
    type: content_moderation_state
    settings: { }
    group_column: value
    group_columns: { }
    group_rows: true
    delta_limit: 0
    delta_offset: 0
    delta_reversed: false
    delta_first_last: false
    multi_type: separator
    separator: ', '
    field_api_classes: false
    pager:
    type: none
    options:
    offset: 0
    exposed_form:
    type: basic
    options:
    submit_button: Apply
    reset_button: false
    reset_button_label: Reset
    exposed_sorts_label: 'Sort by'
    expose_sort_order: true
    sort_asc_label: Asc
    sort_desc_label: Desc
    access:
    type: perm
    options:
    perm: 'access user profiles'
    cache:
    type: tag
    options: { }
    empty: { }
    sorts:
    vid:
    id: vid
    table: node_field_revision
    field: vid
    relationship: uid_revision_test
    group_type: group
    admin_label: ''
    entity_type: node
    entity_field: vid
    plugin_id: standard
    order: ASC
    expose:
    label: ''
    field_identifier: ''
    exposed: false
    arguments: { }
    filters:
    moderation_state:
    id: moderation_state
    table: node_field_revision
    field: moderation_state
    relationship: uid_revision_test
    group_type: group
    admin_label: ''
    entity_type: node
    plugin_id: moderation_state_filter
    operator: in
    value: { }
    group: 1
    exposed: true
    expose:
    operator_id: moderation_state_op
    label: 'Moderation state'
    description: ''
    use_operator: false
    operator: moderation_state_op
    operator_limit_selection: false
    operator_list: { }
    identifier: moderation_state
    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: { }
    style:
    type: default
    row:
    type: fields
    query:
    type: views_query
    options:
    query_comment: ''
    disable_sql_rewrite: false
    distinct: false
    replica: false
    query_tags: { }
    relationships:
    uid_revision_test:
    id: uid_revision_test
    table: users_field_data
    field: uid_revision_test
    relationship: none
    group_type: group
    admin_label: 'node revisions'
    entity_type: user
    plugin_id: standard
    required: true
    header: { }
    footer: { }
    display_extenders: { }
    cache_metadata:
    max-age: -1
    contexts:
    - 'languages:language_content'
    - 'languages:language_interface'
    - url
    - url.query_args
    - user.permissions
    tags:
    - 'config:workflow_list'
    page_1:
    id: page_1
    display_title: Page
    display_plugin: page
    position: 1
    display_options:
    display_extenders: { }
    path: test-content-moderation-filter-revision-relationship
    cache_metadata:
    max-age: -1
    contexts:
    - 'languages:language_content'
    - 'languages:language_interface'
    - url
    - url.query_args
    - user.permissions
    tags:
    - 'config:workflow_list'
    ...@@ -20,3 +20,26 @@ function content_moderation_test_views_views_query_alter(ViewExecutable $view, Q ...@@ -20,3 +20,26 @@ function content_moderation_test_views_views_query_alter(ViewExecutable $view, Q
    $query->addOrderBy('node_field_revision', 'vid', 'ASC'); $query->addOrderBy('node_field_revision', 'vid', 'ASC');
    } }
    } }
    /**
    * Implements hook_views_data_alter().
    *
    * @see \Drupal\Tests\content_moderation\Kernel\ViewsModerationStateFilterTest
    */
    function content_moderation_test_views_views_data_alter(array &$data) {
    if (isset($data['users_field_data'])) {
    $data['users_field_data']['uid_revision_test'] = [
    'help' => t('Relate the content revision to the user who created it.'),
    'real field' => 'uid',
    'relationship' => [
    'title' => t('Content revision authored'),
    'help' => t('Relate the content revision to the user who created it. This relationship will create one record for each content revision item created by the user.'),
    'id' => 'standard',
    'base' => 'node_field_revision',
    'base field' => 'uid',
    'field' => 'uid',
    'label' => t('node revisions'),
    ],
    ];
    }
    }
    ...@@ -240,6 +240,34 @@ public function testModerationStateFilterOnJoinedEntity() { ...@@ -240,6 +240,34 @@ public function testModerationStateFilterOnJoinedEntity() {
    ]); ]);
    $view->execute(); $view->execute();
    $this->assertIdenticalResultset($view, [], ['name' => 'name']); $this->assertIdenticalResultset($view, [], ['name' => 'name']);
    // Revision Data Table Relationship: Filtering by the published state will
    // filter out the sample content.
    $view = Views::getView('test_content_moderation_filter_via_revision_relationship');
    $view->setExposedInput([
    'moderation_state' => 'editorial-published',
    ]);
    $view->execute();
    $this->assertIdenticalResultset($view, [
    [
    'name' => 'Test user',
    'title' => 'Test node',
    'moderation_state' => 'published',
    ],
    ], [
    'name' => 'name',
    'title' => 'title',
    'moderation_state' => 'moderation_state',
    ]);
    // Revision Data Table Relationship: Filtering by the draft state will
    // filter out the sample content.
    $view = Views::getView('test_content_moderation_filter_via_revision_relationship');
    $view->setExposedInput([
    'moderation_state' => 'editorial-draft',
    ]);
    $view->execute();
    $this->assertIdenticalResultset($view, [], ['name' => 'name']);
    } }
    /** /**
    ......
    • catch @catch

      mentioned in commit 98882c4f

      ·

      mentioned in commit 98882c4f

      Toggle commit list
    • catch @catch

      mentioned in commit 87bc567b

      ·

      mentioned in commit 87bc567b

      Toggle commit list
    0% Loading or .
    You are about to add 0 people to the discussion. Proceed with caution.
    Finish editing this message first!
    Please register or to comment