The _fivestar_get_element_default_value function contains a switch/case block with no breaks in. Result is that the default value is always set to the user's vote (the last case in the block).

Patch attached to add the breaks.

CommentFileSizeAuthor
fivestar-break.patch705 bytesmjpa

Comments

Georgii’s picture

Status: Needs review » Reviewed & tested by the community

I have just tested this. Work like a charm.

iaminawe’s picture

I am using 7.x-2.x-dev of Voting API and 7.x-2.x-dev Fivestar with this patch applied and my caches cleared.

I have comments with fivestar fields targeting their parent node and on the node I have the fivestar widget being displayed with this code in the template both using the "vote" tag

    $rating = votingapi_select_single_result_value(array(
        'entity_id' => $entity->nid,
        'entity_type' => 'node',
        'tag' => 'vote',
        'function' => 'average',
   ));
   print theme('fivestar_static', array('rating' => $rating, 'stars' => 5, 'tag' => 'vote'));

When I post a comment with a rating, the stars displayed on the node update to reflect the latest vote even though they are using the 'average' function. Posting a new comment and rating updates them to reflect the new most recent vote but still only one most recent user vote is reflected. This sounds like the issue this patch is addressing but does not seem to work for me. Maybe its because I am using fivestar on comments?

Do you have any suggestions as to what I may be doing wrong? Any help would be greatly appreciated.

Thanks in advance
Gregg

iaminawe’s picture

My mistake - it does work as intended. I didnt realize that a user could only vote once which is why every time I posted a new rating it would replace the old one. its a feature not a bug!!

reevo’s picture

ericduran’s picture

Status: Reviewed & tested by the community » Fixed
Georgii’s picture

Thanks a lot!

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.