I am using Advanced Poll for the actual voting interface. Not sure if this is an Advanced Poll issue or a Voting API issue.

On the output side, I noticed that no matter what relationship I add ("Content: Votes" or "Comment: Votes"), I don't get any vote data back.

It looks like the interpretation of the entity_type column on the "votingapi_vote" table is inconsistent between the views handlers and the rest of the module. For example, the view handler expects entity_type to be either "node" (for "Content: Votes") or "comment" (for "Comment: Votes"), but it's actually "advpoll" (in this case).

I'm guessing that the column is really representing the content type ("advpoll"), rather than the entity type ("node"). I would expect "entity_type" to mean what Views expects -- that it's the type of Drupal 7 entity. If the content type is also needed, I'd expect to see a separate "bundle" column for holding the content type, to match D7 conventions.

Here's an example query from Views:

SELECT comment.subject AS comment_subject, comment.cid AS cid, comment.nid AS comment_nid, node_comment.title AS node_comment_title, node_comment.nid AS node_comment_nid, comment.name AS comment_name, comment.uid AS comment_uid, comment.homepage AS comment_homepage, votingapi_vote_node.value AS votingapi_vote_node_value, votingapi_vote_node.value_type AS votingapi_vote_node_value_type, votingapi_vote_comment.value AS votingapi_vote_comment_value, votingapi_vote_comment.value_type AS votingapi_vote_comment_value_type, comment.created AS comment_created
FROM 
{comment} comment
INNER JOIN {node} node_comment ON comment.nid = node_comment.nid
LEFT JOIN {votingapi_vote} votingapi_vote_node ON node_comment.nid = votingapi_vote_node.entity_id AND votingapi_vote_node.entity_type = 'node'
LEFT JOIN {votingapi_vote} votingapi_vote_comment ON comment.cid = votingapi_vote_comment.entity_id AND votingapi_vote_comment.entity_type = 'comment'
WHERE (( (comment.status <> '0') AND (node_comment.status = '1') ))
ORDER BY comment_created DESC
LIMIT 10 OFFSET 0

Comments

torotil’s picture

Hi, sorry for the late follow-up. Did you upgrade your site from D6 to D7 at some point? My first guess would be that the upgrade-path is broken somehow.

torotil’s picture

Status: Active » Postponed (maintainer needs more info)
Magic03’s picture

Version: 7.x-2.6 » 7.x-2.10
Priority: Major » Critical

Have same problem. Looking into this issue I've found :

SELECT * FROM votingapi_cache

vote_cache_id	entity_type	entity_id	value	value_type	tag	        function	timestamp
1	                advpoll	 9	        1 	percent	6a7b08a5f	count	        1361103754
2	                advpoll	 9	        1	percent	6a7b08a5f	average	1361103754

entity_type is set to type of my voting (Advanced poll) but it should be sent to entity type = 'node'

From API.txt

entity_type -- This *usually* corresponds to a type of Drupal content, like 'node' or 'comment' or 'user'.

Could you please fix it.

torotil’s picture

@Magic03 Did you upgrade this module at some point? What was the version that you used before that?

maulwuff’s picture

I use it on a new site built from scratch. Maybe a look at #1540674: Views Integration may help finding the right module to get this fixed?

Magic03’s picture

2torotil
using fresh install

torotil’s picture

Thanks - having the bug appear in an from-scratch install should make it easier reproducible and fixable. I guess I'll find some time for that in the next few days.

torotil’s picture

Project: Voting API » Advanced Poll
Version: 7.x-2.10 » 7.x-3.x-dev
Status: Postponed (maintainer needs more info) » Active

The voting-module (in this case advpoll) is responsible for giving the correct entity_type. It seems advpoll still uses the node->type instead of the entity_type and thus is incompatible with recent votingapi versions (since 7.x-2.0).

torotil’s picture

Status: Active » Needs review
StatusFileSize
new8.89 KB

Here's a patch that makes advpoll work with the current votingapi-7.x-2.x.

I hope I've caught all instances of "entity_type = advpoll". As I don't use advpoll myself this really needs testing!

tripper54’s picture

Status: Needs review » Closed (duplicate)
Related issues: +#1528052: AJAX error after voting or cancelling a vote