Problem/Motivation

When a content moderator who doesn't have the "tca bypass node" goes to the moderated content overview in the admin interface, it will whitescreen when the tca_node is enabled.

This is because the hook_views_query_alter() on tca_node.module makes an incorrect use of following method:
$info = $query->getEntityTableInfo('node_field_data');

getEntityTableInfo doesn't accept any arguments, and is agnostic towards the query. The logic after this method incorrectly assumes that the node_field_data table is available and attempts to use it.

The website encountered an unexpected error. Try again later.

Drupal\Core\Database\DatabaseExceptionWrapper: Exception in Moderated content[moderated_content]: SQLSTATE[42S22]: Column not found: 1054 Unknown column 'node_field_revision.tca_active' in 'WHERE': SELECT COUNT(*) AS "expression" FROM (SELECT 1 AS "expression" FROM "node_field_revision" "node_field_revision" LEFT JOIN "node_field_data" "node_field_data_node_field_revision" ON node_field_revision.nid = node_field_data_node_field_revision.nid AND node_field_data_node_field_revision.langcode = node_field_revision.langcode LEFT JOIN "users_field_data" "users_field_data_node_field_revision" ON node_field_revision.uid = users_field_data_node_field_revision.uid INNER JOIN (SELECT "base_table"."nid" AS "nid", "base_table"."langcode" AS "langcode", MAX(base_table.vid) AS "vid" FROM "node_field_revision" "base_table" WHERE "base_table"."revision_translation_affected" = :db_condition_placeholder_14 GROUP BY "base_table"."nid", "base_table"."langcode") "node_field_revision2" ON node_field_revision.nid = node_field_revision2.nid AND (node_field_revision2.vid = node_field_revision.vid AND node_field_revision2.langcode = node_field_revision.langcode) LEFT JOIN "content_moderation_state_field_revision" "content_moderation_state" ON node_field_revision.vid = content_moderation_state.content_entity_revision_id AND (content_moderation_state.content_entity_type_id = :views_join_condition_3 AND content_moderation_state.content_entity_id = node_field_revision.nid AND content_moderation_state.langcode = node_field_revision.langcode) INNER JOIN "node" "node" ON node_field_revision.nid = node.nid WHERE (("node_field_revision"."revision_translation_affected" = :db_condition_placeholder_0) AND (("node"."type" IN (:db_condition_placeholder_1, :db_condition_placeholder_2, :db_condition_placeholder_3, :db_condition_placeholder_4, :db_condition_placeholder_5)) AND (("content_moderation_state"."workflow" = :db_condition_placeholder_6) AND ("content_moderation_state"."moderation_state" <> :db_condition_placeholder_7)))) AND (("node_field_revision"."tca_active" IS NULL) OR ("node_field_revision"."tca_active" = :db_condition_placeholder_8) OR ("node_field_revision"."type" IN (:db_condition_placeholder_9, :db_condition_placeholder_10, :db_condition_placeholder_11, :db_condition_placeholder_12, :db_condition_placeholder_13)))) "subquery"; Array ( [:db_condition_placeholder_0] => 1 [:db_condition_placeholder_1] => application [:db_condition_placeholder_2] => event [:db_condition_placeholder_3] => page [:db_condition_placeholder_4] => project [:db_condition_placeholder_5] => update [:db_condition_placeholder_6] => editorial [:db_condition_placeholder_7] => published [:db_condition_placeholder_8] => 0 [:db_condition_placeholder_9] => contact [:db_condition_placeholder_10] => location [:db_condition_placeholder_11] => partner [:db_condition_placeholder_12] => project_owner [:db_condition_placeholder_13] => quote [:db_condition_placeholder_14] => 1 [:views_join_condition_3] => node ) in main() (line 19 of index.php).

Steps to reproduce

  1. Enable tca, tca_node & moderated content
  2. Log in as a user who does not have the tca bypass node permission
  3. Navigate to the Moderated Content page

Proposed resolution

implement $query->getTableInfo('node_field_data') instead, which does check the table info correctly for node_field_data, or returns an empty array if the table isn't present.

Remaining tasks

- Fix the table check for nodes and commerce products
- Add better type safety to avoid future complications

Issue fork tca-3580896

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

mauro_ created an issue. See original summary.

  • mauro_ committed 763c20d6 on 3.0.x
    #3580896: fix issue with views query alter
    
mauro_’s picture

Status: Needs work » Fixed

Fixed and created a new release 3.1.1.
Credited @stefvanlooveren for initial reporting of the issue.

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.

mauro_’s picture

Version: 3.1.0 » 3.1.1
Status: Fixed » Closed (fixed)
mauro_’s picture

Assigned: mauro_ » Unassigned