On my site I've created a content type for creating reviews. Reviews get a rating by the author through the five star module (field_review_rating). The rating is displayed in a block view on the site and next to the article. However the newest review is not displaying the given score in the block on the main page. If I check the element that should provide the score I get the following code:

<div class="fivestar-widget-static fivestar-widget-static-vote fivestar-widget-static-5 clearfix">
<div class="star star-1 star-odd star-first">
<span class="off">0</span>
</div>
<div class="star star-2 star-even">
<span class="off"/>
</div>
<div class="star star-3 star-odd">
<span class="off"/>
</div>
<div class="star star-4 star-even">
<span class="off"/>
</div>
<div class="star star-5 star-odd star-last">
<span class="off"/>
</div>

This is incorrect, because the preview does have, in this case, a rating of 4. When I check the block view through admin/structure/views/view/Review/edit I do see the correct score being displayed in the block. All other items (I display 3 in the single block) do show their rating correctly.

It is very odd behavior, because after some time (might be 1-2 weeks) the score is displayed next to the first block item. Given this behavior I thought it might be cache, but even purging that doesn't show the rating for the first item in my list. The behavior only occurs with the block view associated with the review.

Did I forget something during my initial setup or do we have a bug?

Comments

oobie11’s picture

Same issue here

marcelovani’s picture

After some debugging I found that the block can display the ratings properly only once, which means, if there is a page and a block that display the rating for the same node, the first to render will display it.

In my case I have a page that displays reviews and a block that displays latest reviews. The page displays the ratings correctly but the block comes with no ratings.

marcelovani’s picture

Status: Active » Needs review
Issue tags: +fivestar bug block rating
StatusFileSize
new1.6 KB

The bug happens is due to the fact that the first time the ratings are processed, the array of items is overridden and the information is no longer available on the second render.

I am attaching a patch that creates an extra key on the array, keeping the original keys untouched.

Status: Needs review » Needs work

The last submitted patch, rating_not_showing_block_on_site-1506582-854220.patch, failed testing.

ericduran’s picture

This makes sense. But it seems like is breaking some of the test.

We should get fix the issue and hopefully get this in.

ericduran’s picture

Status: Needs work » Needs review
Issue tags: -fivestar bug block rating

Status: Needs review » Needs work
Issue tags: +fivestar bug block rating

The last submitted patch, rating_not_showing_block_on_site-1506582-854220.patch, failed testing.

marcelovani’s picture

The tests are failing but should be something else, not related to the fix.
I have been using this patch for nearly a month now and it works well.

marcelovani’s picture

Status: Needs work » Needs review
Issue tags: -fivestar bug block rating

Status: Needs review » Needs work
Issue tags: +fivestar bug block rating

The last submitted patch, rating_not_showing_block_on_site-1506582-854220.patch, failed testing.

marcelovani’s picture

Status: Needs work » Needs review
StatusFileSize
new1.57 KB

Re-patched and tested locally, need help to test it and possibly getting this fix committed.
To simulate the problem

  • Create an entity and create a field: rating, which will be a fivestar
  • Create two blocks that display the same nodes, i.e. popular nodes, latest nodes
  • You will notice that on the first block, the ratings will display correctly, but on the second block they will come without rating
  • Apply the patch and see if it works now.
marcelovani’s picture

Status: Needs review » Needs work

The last submitted patch, rating_not_showing_on_blocks-1506582-11.patch, failed testing.

fenda’s picture

The patch in #11 worked for me.

kristen pol’s picture

Status: Needs work » Reviewed & tested by the community

Patch #11 works great!

Berliner-dupe’s picture

Status: Needs work » Reviewed & tested by the community

Patch 11 make new errors ...

Now Fivestar will show in Views-Block correct but in Node only when Stars (rated while editing) is selected. If you select Stars (rated while viewing) Fivestar-field will not show in all new Nodes as normal field.

The Fivestar-Fields in new Nodes show only label now - the Fivestar-Widget is away. I tested a few content-types - same problem everywhere.

Has anyone an idea?

Berliner-dupe’s picture

Status: Reviewed & tested by the community » Needs work
end user’s picture

Status: Reviewed & tested by the community » Needs work

The patch in #11 worked for me with fivestar-7.x-2.x-dev Oct 23/2013

s_gupta_14’s picture

Was facing same issue patch #11 worked for me

marcoka’s picture

#11 helped me too. Without it my site went to shit :)
thank you.
i will monitor if i will have the same problems as "Berliner" and report back.

marcoka’s picture

Priority: Normal » Major
Issue summary: View changes
whiteph’s picture

Priority: Major » Normal

Reduced priority back to "Normal". See Priority levels of issues. Normal is: Bugs that affect one piece of functionality are normal priority. An example would be the category filter not working on the database log screen. This is a self-contained bug and does not impact the overall functionality of the software.

I re-rolled the patch for the latest 7.x-2.x-dev release, and the tests still fail dramatically i.e. this patch breaks normal functionality. I'll take a more detailed look at this issue, but it will have to wait for its turn in the queue.

marcelovani’s picture

Status: Needs work » Fixed

In fact the problem no longer exists.
I believe the fix happened here https://drupal.org/node/1853760
I would suggest to close this ticket.

whiteph’s picture

Great, thanks for the feedback.

Status: Fixed » Closed (fixed)

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