Views doesn't fetch voted entity

Created on 17 March 2019, almost 6 years ago
Updated 14 September 2023, over 1 year ago

I've created a view to display recent votes for media entities but it shows empty entity fields (id, title and other). See view export attached.
The reason is bad query:

SELECT votingapi_vote.timestamp AS votingapi_vote_timestamp, votingapi_vote.id AS id, node_field_data_votingapi_vote.nid AS node_field_data_votingapi_vote_nid
FROM
{votingapi_vote} votingapi_vote
LEFT JOIN {node_field_data} node_field_data_votingapi_vote ON votingapi_vote.entity_id = node_field_data_votingapi_vote.nid
ORDER BY votingapi_vote_timestamp DESC
LIMIT 51 OFFSET 0

Why `node_field_data` table is used? Here we have media type entity not node.
Any ideas how to fix it?

πŸ› Bug report
Status

Active

Version

3.0

Component

Views Integration

Created by

πŸ‡·πŸ‡ΊRussia i-grou

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • πŸ‡¬πŸ‡§United Kingdom jaydenpearly

    4 years later, the same problem still persists. Indicates that an unrelated node was voted on when you voted for a media.
    If the node to which the media is connected appears to be voted, we will analyze it as well. But it seems like another unrelated node has been voted in the views table even though the media is voted.

  • πŸ‡ΊπŸ‡ΈUnited States tr Cascadia

    "4 years later, the same problem still persists"

    And in those 4 years, there have been exactly zero other reports of this problem. Likewise, there are no details that we can use to try to reproduce the problem, no tests written that demonstrate the problem, and no patches contributed that provide a fix.

    @jaydenpearly: If you want to help out, you can detail the steps that must be followed - on a clean site - in order to reproduce this problem.

  • πŸ‡¬πŸ‡§United Kingdom Rob230

    I'm seeing something similar (to the issue title anyway).

    I have added a rate widget to paragraph entities, and voted.

    You can see here that I have 2 votes, with entity IDs:

    id	type	uuid	entity_type	entity_id	value	value_type	user_id	timestamp	vote_source	rate_widget
    16	updown	1c5a19bc-3924-4d57-92e3-97515db64e38	paragraph	184	1	points	1	1694689401	a36fd09186fc87f08b70ee61bf531b1693a7a5315ae3daff0619756988da5311	like_widget
    17	updown	d69d6d18-fc3d-498f-ad12-dc87232d651a	paragraph	126	1	points	1	1694689905	a36fd09186fc87f08b70ee61bf531b1693a7a5315ae3daff0619756988da5311	like_widget
    

    I have added the "Vote: Voted entity" field with "Entity ID" formatter. And the result is blank. If I show the SQL in Views, it is doing this:

    SELECT "votingapi_vote"."id" AS "id"
    FROM
    {votingapi_vote} "votingapi_vote"
    WHERE ("votingapi_vote"."type" IN ('updown')) AND ("votingapi_vote"."entity_type" LIKE 'paragraph' ESCAPE '\\')
    LIMIT 11 OFFSET 0

    No attempt has been made to fetch the entity ID column.

    I believe it does work for the entity type of node. The views integration is just broken for other entity types.

  • πŸ‡¬πŸ‡§United Kingdom Rob230

    It looks like the patches on #2988057: Voting API REST POST (create with REST) doesn't work, validation error, when referenced entity other than node β†’ do make this field work, so I can at least see the paragraph ID.

    Unfortunately, there are no relationships that can be made from it (e.g. to the paragraph). There is just a "Content" ("The ID from the voted entity") relationship, which joins to node_field_data causing there to be no results.

Production build 0.71.5 2024